Skip to content

Commit

Permalink
Merge pull request #47 from alekodu/dev
Browse files Browse the repository at this point in the history
Support customizable cpu, memory, network task complexities
  • Loading branch information
salehsedghpour authored May 3, 2022
2 parents 2c016f0 + 2b77f26 commit 43e77ac
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 158 deletions.
126 changes: 104 additions & 22 deletions generator/examples/simple/application_description.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"cluster_latencies": [
{
"src" : "cluster-1",
"dest": "cluster-2",
"src" : "cluster1",
"dest": "cluster2",
"latency": 0.002
}
],
Expand All @@ -11,41 +11,123 @@
"name": "service1",
"clusters": [
{
"cluster": "cluster-1",
"cluster": "cluster1",
"namespace": "default",
"node": "node-1"
"node": "cluster1-control-plane"
}
],
"resources": {
"limits": {
"memory": "1024M",
"cpu": "1000m"
"cpu": "2000m"
},
"requests": {
"memory": "512M",
"cpu": "500m"
"memory": "1024M",
"cpu": "2000m"
}
},
"processes": 2,
"threads": 2,
"readiness_probe": 1,
"endpoints": [
{
"name": "endpoint1",
"protocol": "http",
"execution_mode": "sequential",
"network_complexity": {
"forward_requests": "asynchronous",
"response_payload_size": 512,
"called_services": [
{
"service": "service2",
"port": "80",
"endpoint": "endpoint1",
"protocol": "http",
"traffic_forward_ratio": 1,
"request_payload_size": 256
},
{
"service": "service2",
"port": "80",
"endpoint": "endpoint2",
"protocol": "http",
"traffic_forward_ratio": 1,
"request_payload_size": 256
}
]
}
},
{
"name": "endpoint2",
"protocol": "http",
"execution_mode": "parallel",
"network_complexity": {
"forward_requests": "asynchronous",
"response_payload_size": 512,
"called_services": [
]
}
}
]
},
{
"name": "service2",
"clusters": [
{
"cluster": "cluster1",
"namespace": "default",
"node": "cluster1-control-plane"
}
],
"resources": {
"limits": {
"memory": "1024M",
"cpu": "2000m"
},
"requests": {
"memory": "1024M",
"cpu": "2000m"
}
},
"processes": 2,
"threads": 2,
"readiness_probe": 5,
"readiness_probe": 1,
"endpoints": [
{
"name": "end1",
"name": "endpoint1",
"protocol": "http",
"execution_mode": "parallel",
"cpu_complexity": {
"execution_time": "1s",
"method": "fibonacci",
"workers": 2,
"cpu_affinity": [
1,
2
],
"cpu_load": "10%"
},
"memory_complexity": {
"execution_time": "1s",
"method": "swap",
"workers": 24,
"bytes_load": "10%"
},
"network_complexity": {
"forward_requests": "asynchronous",
"response_payload_size": 512,
"called_services": []
}
},
{
"name": "endpoint2",
"protocol": "http",
"cpu_consumption": 0.003,
"network_consumption": 0.002,
"memory_consumption": 0.003,
"forward_requests": "asynchronous",
"called_services": [
{
"service": "service2",
"port": "80",
"endpoint": "end2",
"protocol": "http",
"traffic_forward_ratio": 1
}
]
"execution_mode": "parallel",
"network_complexity": {
"forward_requests": "asynchronous",
"response_payload_size": 512,
"called_services": []
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ metadata:
name: config-service1
labels:
name: config-service1
version: cluster-1
version: cluster1
namespace: default
data:
conf.json: '{"processes":2,"threads":2,"endpoints":[{"name":"end1","protocol":"http","cpu_consumption":0.003,"network_consumption":0.002,"memory_consumption":0.003,"forward_requests":"asynchronous","called_services":[{"service":"service2","port":"80","endpoint":"end2","protocol":"http","traffic_forward_ratio":1}]}]}'
service.proto: "syntax = \"proto3\";\n\n\nservice service1 {\n \n rpc end1 (Request) returns (Response) {}\n \n}\n\n\nmessage Request {\n string data = 1;\n}\n\nmessage Response {\n string data = 1;\n}"
conf.json: '{"processes":2,"threads":2,"endpoints":[{"name":"endpoint1","protocol":"http","execution_mode":"sequential","network_complexity":{"forward_requests":"asynchronous","response_payload_size":512,"called_services":[{"service":"service2","port":"80","endpoint":"endpoint1","protocol":"http","traffic_forward_ratio":1,"request_payload_size":256},{"service":"service2","port":"80","endpoint":"endpoint2","protocol":"http","traffic_forward_ratio":1,"request_payload_size":256}]}},{"name":"endpoint2","protocol":"http","execution_mode":"parallel","network_complexity":{"forward_requests":"asynchronous","response_payload_size":512,"called_services":[]}}]}'
service.proto: "syntax = \"proto3\";\n\n\nservice service1 {\n \n rpc endpoint1 (Request) returns (Response) {}\n \n rpc endpoint2 (Request) returns (Response) {}\n \n}\n\nservice service2 {\n \n rpc endpoint1 (Request) returns (Response) {}\n \n rpc endpoint2 (Request) returns (Response) {}\n \n}\n\n\nmessage Request {\n string data = 1;\n}\n\nmessage Response {\n string data = 1;\n}"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: service1
namespace: default
labels:
version: cluster-1
version: cluster1
spec:
selector:
matchLabels:
app: service1
version: cluster-1
version: cluster1
replicas: 1
template:
metadata:
labels:
app: service1
version: cluster-1
version: cluster1
spec:
nodeName: node-1
nodeName: cluster1-control-plane
containers:
- name: app
image: app-demo:latest
Expand All @@ -46,15 +46,15 @@ spec:
httpGet:
path: /
port: 5000
initialDelaySeconds: 5
initialDelaySeconds: 1
periodSeconds: 1
resources:
limits:
cpu: 1000m
cpu: 2000m
memory: 1024M
requests:
cpu: 500m
memory: 512M
cpu: 2000m
memory: 1024M
volumes:
- name: config-data-volume
configMap:
Expand All @@ -66,7 +66,7 @@ metadata:
name: service1
namespace: default
labels:
version: cluster-1
version: cluster1
annotations:
http: /
spec:
Expand Down
78 changes: 78 additions & 0 deletions generator/examples/simple/cluster1/service2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: config-service2
labels:
name: config-service2
version: cluster1
namespace: default
data:
conf.json: '{"processes":2,"threads":2,"endpoints":[{"name":"endpoint1","protocol":"http","execution_mode":"parallel","cpu_complexity":{"execution_time":"1s","method":"fibonacci","workers":2,"cpu_affinity":[1,2],"cpu_load":"10%"},"memory_complexity":{"execution_time":"1s","method":"swap","workers":24,"bytes_load":"10%"},"network_complexity":{"forward_requests":"asynchronous","response_payload_size":512,"called_services":[]}},{"name":"endpoint2","protocol":"http","execution_mode":"parallel","network_complexity":{"forward_requests":"asynchronous","response_payload_size":512,"called_services":[]}}]}'
service.proto: "syntax = \"proto3\";\n\n\nservice service1 {\n \n rpc endpoint1 (Request) returns (Response) {}\n \n rpc endpoint2 (Request) returns (Response) {}\n \n}\n\nservice service2 {\n \n rpc endpoint1 (Request) returns (Response) {}\n \n rpc endpoint2 (Request) returns (Response) {}\n \n}\n\n\nmessage Request {\n string data = 1;\n}\n\nmessage Response {\n string data = 1;\n}"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: service2
namespace: default
labels:
version: cluster1
spec:
selector:
matchLabels:
app: service2
version: cluster1
replicas: 1
template:
metadata:
labels:
app: service2
version: cluster1
spec:
nodeName: cluster1-control-plane
containers:
- name: app
image: app-demo:latest
imagePullPolicy: Never
env:
- name: SERVICE_NAME
value: service2
ports:
- containerPort: 5000
volumeMounts:
- mountPath: /usr/src/app/config
name: config-data-volume
readinessProbe:
httpGet:
path: /
port: 5000
initialDelaySeconds: 1
periodSeconds: 1
resources:
limits:
cpu: 2000m
memory: 1024M
requests:
cpu: 2000m
memory: 1024M
volumes:
- name: config-data-volume
configMap:
name: config-service2
---
apiVersion: v1
kind: Service
metadata:
name: service2
namespace: default
labels:
version: cluster1
annotations:
http: /
spec:
selector:
app: service2
ports:
- name: http
port: 80
targetPort: 5000
44 changes: 31 additions & 13 deletions generator/input/new_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,37 @@
{
"name": "end1",
"protocol": "http",
"cpu_consumption": 0.003,
"network_consumption": 0.002,
"memory_consumption": 0.003,
"forward_requests": "asynchronous",
"called_services": [
{
"service": "service2",
"port": "80",
"endpoint": "end2",
"protocol": "http",
"traffic_forward_ratio": 1
}
]
"execution_mode": "sequential",
"cpu_complexity": {
"execution_time": "1s",
"method": "fibonacci",
"workers": 2,
"cpu_affinity": [
0,
2
],
"cpu_load": "10%"
},
"memory_complexity": {
"execution_time": "1s",
"method": "swap",
"workers": 2,
"bytes_load": "10%"
},
"network_complexity": {
"forward_requests": "asynchronous",
"response_payload_size": 256,
"called_services": [
{
"service": "service2",
"port": "80",
"endpoint": "end2",
"protocol": "http",
"traffic_forward_ratio": 1,
"request_payload_size": 512
}
]
}
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions generator/src/pkg/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func CreateK8sYaml(config model.FileConfig, clusters []string) {
for j := 0; j < len(config.Services[i].Clusters); j++ {
directory := config.Services[i].Clusters[j].Cluster
directory_path := fmt.Sprintf(path+"/%s", directory)
c_id := fmt.Sprintf("%s", config.Services[i].Clusters[j].Cluster)
c_id := config.Services[i].Clusters[j].Cluster
nodeAffinity := config.Services[i].Clusters[j].Node
namespace := config.Services[i].Clusters[j].Namespace
manifestFilePath := fmt.Sprintf(directory_path+"/%s.yaml", serv)
Expand Down Expand Up @@ -234,7 +234,7 @@ func CreateJsonInput(userConfig model.UserConfig) string {
// NOTE: Always calling the first endpoint of the called service
calledService.Endpoint = s.EpNamePrefix + "1"

endpoint.CalledServices = append(endpoint.CalledServices, calledService)
endpoint.NetworkComplexity.CalledServices = append(endpoint.NetworkComplexity.CalledServices, calledService)
}
}

Expand Down
Loading

0 comments on commit 43e77ac

Please sign in to comment.