Skip to content

Commit 9de59c4

Browse files
authored
V0.4.1 (#35)
* Prepare next release * Docs: Improve * self.connectionmanagement['singleConnection'] optional * Docs: Improve API * K8s: Stop experiment does not delete pod * Docs: Improve API * Docs: Improve API * K8s: Script as metadata * K8s: Escape DBMS password * TPC-H: Dialect TSQL and Oracle * TPC-H: Demo config * TPC-H: Demo Exasol, OracleDB, SQLServer
1 parent a2ab975 commit 9de59c4

20 files changed

+1775
-136
lines changed

bexhoma/masterK8s.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def startExperiment(self, instance=None, volume=None, docker=None, script=None,
174174
def stopExperiment(self, delay=0):
175175
self.getInfo()
176176
self.stopPortforwarding()
177-
for p in self.pods:
178-
self.deletePod(p)
177+
#for p in self.pods:
178+
# self.deletePod(p)
179179
experiment = {}
180180
experiment['delay'] = delay
181181
experiment['step'] = "stopExperiment"
@@ -453,7 +453,7 @@ def kubectl(self, command):
453453
print(command)
454454
os.system(command)
455455
def executeCTL(self, command):
456-
fullcommand = 'kubectl exec '+self.activepod+' --container=dbms -- bash -c "'+command+'"'
456+
fullcommand = 'kubectl exec '+self.activepod+' --container=dbms -- bash -c "'+command.replace('"','\\"')+'"'
457457
print(fullcommand)
458458
proc = subprocess.Popen(fullcommand, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
459459
stdout, stderr = proc.communicate()
@@ -635,6 +635,7 @@ def runBenchmarks(self, connection=None, code=None, info=[], resultfolder='', co
635635
c['active'] = True
636636
c['name'] = connection
637637
c['docker'] = self.d
638+
c['script'] = self.s
638639
c['info'] = info
639640
c['timeLoad'] = self.timeLoading
640641
c['priceperhourdollar'] = 0.0 + self.docker['priceperhourdollar']
@@ -670,7 +671,7 @@ def runBenchmarks(self, connection=None, code=None, info=[], resultfolder='', co
670671
c['connectionmanagement']['numProcesses'] = self.connectionmanagement['numProcesses']
671672
c['connectionmanagement']['runsPerConnection'] = self.connectionmanagement['runsPerConnection']
672673
c['connectionmanagement']['timeout'] = self.connectionmanagement['timeout']
673-
c['connectionmanagement']['singleConnection'] = self.connectionmanagement['singleConnection']
674+
c['connectionmanagement']['singleConnection'] = self.connectionmanagement['singleConnection'] if 'singleConnection' in self.connectionmanagement else False
674675
c['monitoring'] = {}
675676
if 'monitor' in self.config['credentials']['k8s']:
676677
if 'grafanatoken' in self.config['credentials']['k8s']['monitor']:

demo-tpch-k8s.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
cluster.set_connectionmanagement(
6868
numProcesses = 1,
6969
runsPerConnection = 0,
70-
timeout = 600,
71-
singleConnection = False)
70+
timeout = 600)
7271

7372
# set query parameters - this overwrites infos given in the query file
7473
cluster.set_querymanagement(numRun = 1)
@@ -84,7 +83,7 @@
8483
'memory': 0
8584
},
8685
nodeSelector = {
87-
'cpu': cpu_type,
86+
#'cpu': cpu_type,
8887
})
8988

9089

@@ -97,8 +96,8 @@ def run_experiments(docker, alias):
9796
for i in range(1,numExperiments+1):
9897
connection = cluster.getConnectionName()
9998
cluster.runBenchmarks(connection=connection+"-"+str(i), alias=alias+'-'+str(i))
100-
cluster.stopExperiment()
101-
cluster.cleanExperiment()
99+
cluster.stopExperiment(delay=60)
100+
cluster.cleanExperiment(delay=60)
102101
del gc.garbage[:]
103102

104103

docs/API.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,26 @@ This document contains API details about
1212

1313
## Set Code
1414

15+
Sets a code for the collection of experiments.
16+
This is used by the benchmarking package https://github.com/Beuth-Erdelt/DBMS-Benchmarker
17+
18+
For a new experiment the code is `None`.
19+
1520
## Set Experiment
1621

22+
```
23+
cluster.setExperiment(instance, volume, docker, script)
24+
```
25+
This sets (up to) four central parameter of an experiment
26+
* `instance`: Name of virtual machine
27+
* `volume`: Name of Storage Device
28+
* `docker`: Name of DBMS docker image
29+
* `script`: Name of collection of init scripts
30+
31+
The four parameter are given as keys to improve usability, for example `script="SF1-indexes"` and `instance="4000m-16Gi"`.
32+
Most of these keys are translated into technical details using a configuration file, c.f. an [example](../k8s-cluster.config).
33+
Instances in a Kubernetes cluster are translated using [YAML files](#deployments).
34+
1735
## Run Experiment
1836

1937
<p align="center">
@@ -46,21 +64,41 @@ cluster.setExperiment(instance, volume, docker, script)
4664
cluster.createDeployment()
4765
cluster.startPortforwarding()
4866
```
49-
* `cluster.createDeployment()`: Creates a deployment of a docker image (pod and services) to k8s
67+
* `cluster.createDeployment()`: Creates a deployment (pod and services) of Docker images to k8s
68+
* Setup Network `cluster.startPortforwarding()`: Forwards the port of the DBMS in the pod to localhost:fixedport (same for all containers)
69+
70+
#### Deployments
71+
5072
The deployment is expected to be given as a file named `'deployment-'+docker+'-'+instance+'.yml'`
5173
If no such file exists, a file named `'deploymenttemplate-"+docker+".yml'` is loaded and
52-
* the instance name is understood as `cpu-mem-gpu-node`
74+
* the instance name is understood as `cpu-mem-gpu-gputype`
5375
* the yaml file is changed as
5476
```
5577
dep['spec']['template']['spec']['containers'][0]['resources']['requests']['cpu'] = cpu
5678
dep['spec']['template']['spec']['containers'][0]['resources']['limits']['cpu'] = cpu
5779
dep['spec']['template']['spec']['containers'][0]['resources']['requests']['memory'] = mem
5880
dep['spec']['template']['spec']['containers'][0]['resources']['limits']['memory'] = mem
59-
dep['spec']['template']['spec']['nodeSelector']['gpu'] = node
81+
dep['spec']['template']['spec']['nodeSelector']['gpu'] = gputype
6082
dep['spec']['template']['spec']['containers'][0]['resources']['limits']['nvidia.com/gpu'] = int(gpu)
6183
```
6284
* saved as `'deployment-'+docker+'-'+instance+'.yml'`
63-
* Setup Network `cluster.startPortforwarding()`: Forwards the port of the DBMS in the pod to localhost:fixedport (same for all containers)
85+
86+
The resources (requests, limits and nodeSelector) can also be set explicitly using
87+
```
88+
cluster.set_resources(
89+
requests = {
90+
'cpu': cpu,
91+
'memory': mem
92+
},
93+
limits = {
94+
'cpu': 0, # unlimited
95+
'memory': 0 # unlimited
96+
},
97+
nodeSelector = {
98+
'cpu': cpu_type,
99+
'gpu': gpu_type,
100+
})
101+
```
64102

65103
### On AWS
66104

@@ -156,9 +194,26 @@ cluster.runBenchmarks(connection=connectionname+"-2clients")
156194

157195
Simulated clients can optionally be configured via a connection manager:
158196
```
159-
cluster.connectionmanagement['numProcesses'] = 8
160-
cluster.connectionmanagement['runsPerConnection'] = 5
161-
cluster.connectionmanagement['timeout'] = 1200
197+
cluster.set_connectionmanagement(
198+
numProcesses = 2,
199+
runsPerConnection = 0,
200+
timeout = 600)
201+
```
202+
203+
### Workload Configurations
204+
205+
The workload is set in the configuration of the experiment
206+
```
207+
cluster = testdesign(queryfile = queryfile)
208+
```
209+
210+
The workload can be further manipulated:
211+
```
212+
cluster.set_workload(
213+
name = 'TPC-H Queries',
214+
info = 'This experiment compares instances of different DBMS on different machines.')
215+
216+
cluster.set_querymanagement(numRun = 64)
162217
```
163218

164219
### Collect Results
@@ -181,6 +236,8 @@ The result folder also contains
181236

182237
**Note this means it stores confidential informations**
183238

239+
Results are inspected best using the [dashboard](https://github.com/Beuth-Erdelt/DBMS-Benchmarker/blob/master/docs/Dashboard.md)
240+
184241
### Collect Host Informations
185242

186243
Some information is given by configuration (JDBC data e.g.), some is collected from the experiment host:
@@ -232,13 +289,14 @@ The command `cluster.stopExperiment()` (basically) is short for:
232289
```
233290
cluster.getInfo()
234291
cluster.stopPortforwarding()
235-
for p in cluster.pods:
236-
cluster.deletePod(p)
292+
#for p in cluster.pods:
293+
# cluster.deletePod(p)
237294
```
238295

239296
* `cluster.stopPortforwarding()`: Disconnects network from current pod
240-
* `cluster.deletePod()`: Deletes all pods belonging to namespace / matching label app. Note that the deployment will automatically start a new (clean) pod. Also note that the pod nevertheless will keep data if the storage device has been mounted.
297+
* ~~`cluster.deletePod()`: Deletes all pods belonging to namespace / matching label app. Note that the deployment will automatically start a new (clean) pod. Also note that the pod nevertheless will keep data if the storage device has been mounted.~~
241298

299+
**Note: The pod is not deleted anymore**
242300

243301
### On AWS
244302

docs/Example-TPC-H.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Official TPC-H benchmark - http://www.tpc.org/tpch
1515

1616
We need configuration file containing the following informations in a predefined format, c.f. [demo file](../k8s-cluster.config).
1717
We may adjust the configuration to match the actual environment.
18+
This in particular holds for `imagePullSecrets`, `tolerations` and `nodeSelector` in the YAML files.
19+
1820
The demo also includes the necessary settings for some DBMS: MariaDB, MonetDB, MySQL, OmniSci and PostgreSQL.
1921

2022
For basic execution of benchmarking we need

docs/deploymenttemplate-PostgreSQL.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
labels: {app: bexhoma}
5-
name: service-bexhoma
5+
name: bexhoma-service
66
spec:
77
ports:
88
- {port: 9091, protocol: TCP, name: port-dbms, targetPort: 5432}
@@ -13,16 +13,17 @@ apiVersion: apps/v1
1313
kind: Deployment
1414
metadata:
1515
labels: {app: bexhoma}
16-
name: deployment-bexhoma
16+
name: bexhoma-deployment-postgres
1717
spec:
1818
replicas: 1
1919
selector:
2020
matchLabels: {app: bexhoma}
2121
template:
2222
metadata:
23-
labels: {app: bexhoma, env: test}
23+
labels: {app: bexhoma}
2424
spec:
2525
automountServiceAccountToken: false
26+
nodeSelector: {cpu: epyc-7542}
2627
containers:
2728
- name: dbms
2829
image: postgres:11.4
@@ -62,10 +63,9 @@ spec:
6263
- mountPath: /dev/disk
6364
name: disk
6465
readOnly: true
65-
nodeSelector: {cpu: epyc-7542}
6666
volumes:
6767
- name: benchmark-data-volume
68-
persistentVolumeClaim: {claimName: data-benchmarking}
68+
persistentVolumeClaim: {claimName: vol-benchmarking}
6969
- hostPath:
7070
path: /
7171
name: rootfs
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- sccsid: @(#)dss.ri 2.1.8.1
2+
-- tpcd benchmark version 8.0
3+
4+
-- for table nation
5+
alter table public.nation
6+
add foreign key (n_regionkey) references public.region(r_regionkey);
7+
8+
-- for table supplier
9+
alter table public.supplier
10+
add foreign key (s_nationkey) references public.nation(n_nationkey);
11+
12+
-- for table customer
13+
alter table public.customer
14+
add foreign key (c_nationkey) references public.nation(n_nationkey);
15+
16+
-- for table partsupp
17+
alter table public.partsupp
18+
add foreign key (ps_suppkey) references public.supplier(s_suppkey);
19+
20+
alter table public.partsupp
21+
add foreign key (ps_partkey) references public.part(p_partkey);
22+
23+
-- for table orders
24+
alter table public.orders
25+
add foreign key (o_custkey) references public.customer(c_custkey);
26+
27+
-- for table lineitem
28+
alter table public.lineitem
29+
add foreign key (l_orderkey) references public.orders(o_orderkey);
30+
31+
alter table public.lineitem
32+
add foreign key (l_partkey,l_suppkey) references
33+
public.partsupp(ps_partkey,ps_suppkey);
34+
35+
36+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
IMPORT INTO public.customer FROM LOCAL CSV FILE '/data/tpch/SF1/customer.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
2+
IMPORT INTO public.lineitem FROM LOCAL CSV FILE '/data/tpch/SF1/lineitem.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
3+
IMPORT INTO public.nation FROM LOCAL CSV FILE '/data/tpch/SF1/nation.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
4+
IMPORT INTO public.orders FROM LOCAL CSV FILE '/data/tpch/SF1/orders.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
5+
IMPORT INTO public.part FROM LOCAL CSV FILE '/data/tpch/SF1/part.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
6+
IMPORT INTO public.partsupp FROM LOCAL CSV FILE '/data/tpch/SF1/partsupp.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
7+
IMPORT INTO public.region FROM LOCAL CSV FILE '/data/tpch/SF1/region.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
8+
IMPORT INTO public.supplier FROM LOCAL CSV FILE '/data/tpch/SF1/supplier.tbl' COLUMN SEPARATOR = '|' SKIP = 0;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- indexes for foreign keys
2+
3+
-- for table region
4+
alter table public.region
5+
add primary key (r_regionkey);
6+
7+
-- for table nation
8+
alter table public.nation
9+
add primary key (n_nationkey);
10+
11+
-- create index on public.nation (n_regionkey);
12+
13+
-- for table part
14+
alter table public.part
15+
add primary key (p_partkey);
16+
17+
-- for table supplier
18+
alter table public.supplier
19+
add primary key (s_suppkey);
20+
21+
-- create index on public.supplier (s_nationkey);
22+
23+
-- for table partsupp
24+
alter table public.partsupp
25+
add primary key (ps_partkey,ps_suppkey);
26+
27+
-- for table customer
28+
alter table public.customer
29+
add primary key (c_custkey);
30+
31+
-- create index on public.customer (c_nationkey);
32+
33+
-- for table partsupp
34+
-- create index on public.partsupp (ps_suppkey);
35+
36+
-- create index on public.partsupp (ps_partkey);
37+
38+
-- for table lineitem
39+
alter table public.lineitem
40+
add primary key (l_orderkey,l_linenumber);
41+
42+
-- for table orders
43+
alter table public.orders
44+
add primary key (o_orderkey);
45+
46+
-- create index on public.orders (o_custkey);
47+
48+
-- for table lineitem
49+
-- create index on public.lineitem (l_orderkey);
50+
51+
-- create index on public.lineitem (l_partkey,l_suppkey);
52+

0 commit comments

Comments
 (0)