summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2018-01-08 21:37:16 -0200
committerdrebs <drebs@riseup.net>2018-01-08 21:37:16 -0200
commitdffcd8a954225dedc51beae01baf0966ce92e155 (patch)
treeedfff05dc22d0147b58e5318e44204f709604606
parent3e8df5c794656e8bad5e620673d457af86de745d (diff)
use ab in blobs multiprocess test
-rw-r--r--blobs-multiprocess/blobs-server.py18
-rwxr-xr-xblobs-multiprocess/graph.py37
-rw-r--r--blobs-multiprocess/makefile74
-rwxr-xr-xblobs-multiprocess/request.py16
-rw-r--r--blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.pngbin28879 -> 0 bytes
-rw-r--r--blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt24
-rw-r--r--blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.pngbin28954 -> 0 bytes
-rw-r--r--blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt24
-rw-r--r--blobs-multiprocess/results/blobs-in-parallel-1.pngbin27957 -> 0 bytes
-rwxr-xr-xblobs-multiprocess/run-test.sh122
10 files changed, 192 insertions, 123 deletions
diff --git a/blobs-multiprocess/blobs-server.py b/blobs-multiprocess/blobs-server.py
index 74d5e62..146b315 100644
--- a/blobs-multiprocess/blobs-server.py
+++ b/blobs-multiprocess/blobs-server.py
@@ -5,7 +5,6 @@ import os
from argparse import ArgumentParser
from sys import stdout
-
from twisted.internet import reactor
from twisted.python import log
from twisted.web.resource import Resource
@@ -40,8 +39,23 @@ class DummyResource(Resource):
return ''
+class RootResource(Resource):
+
+ def __init__(self, port, *args, **kwargs):
+ Resource.__init__(self, *args, **kwargs)
+ self.prefix = str(port) + "-"
+ self.blob_id = 0
+
+ def getChildWithDefault(self, path, request):
+ if path == 'blobs' and len(request.postpath) == 2:
+ blob_id = "{}{}".format(self.prefix, str(self.blob_id))
+ request.postpath[1] = blob_id
+ self.blob_id += 1
+ return Resource.getChildWithDefault(self, path, request)
+
+
def start_server(dir, port):
- resource = Resource()
+ resource = RootResource(port)
resource.putChild("", DummyResource())
resource.putChild("blobs", BlobsResource("filesystem", dir))
site = Site(resource)
diff --git a/blobs-multiprocess/graph.py b/blobs-multiprocess/graph.py
index f1f832e..95ae8de 100755
--- a/blobs-multiprocess/graph.py
+++ b/blobs-multiprocess/graph.py
@@ -9,33 +9,26 @@ style.use('ggplot')
graphs = [
'baseline',
- 'list',
'put',
- 'get',
+ 'list',
'flag',
+ 'get',
'delete',
]
-labels = [
- 'baseline',
- 'list',
- 'put',
- 'put+get',
- 'put+flag',
- 'put+delete',
-]
-
def get_data():
data = {}
with open('results.txt') as f:
for line in f.readlines():
- procs, action, amount, size, mean = line.split()
- if int(amount) != 1000:
+ line = line.strip()
+ if not line:
continue
+ procs, action, rps = line.split()
if procs not in data:
data[procs] = {}
- data[procs][action] = float(mean)
+ data[procs][action] = 0
+ data[procs][action] = float(rps)
return data
@@ -47,28 +40,28 @@ def plot_data(data):
width = 0.20 # the width of the bars
fig, ax = plt.subplots()
- vals = [1000. / data['1'][action] for action in graphs]
+ vals = [data['1'][action] for action in graphs]
rects1 = ax.bar(ind, vals, width)
- vals = [1000. / data['2'][action] for action in graphs]
+ vals = [data['2'][action] for action in graphs]
rects2 = ax.bar(ind + width, vals, width)
- vals = [1000. / data['4'][action] for action in graphs]
+ vals = [data['3'][action] for action in graphs]
rects3 = ax.bar(ind + (2 * width), vals, width)
- vals = [1000. / data['8'][action] for action in graphs]
+ vals = [data['4'][action] for action in graphs]
rects4 = ax.bar(ind + (3 * width), vals, width)
# add some text for labels, title and axes ticks
ax.set_ylabel('Requests per second')
ax.set_title('How multiprocessing affects Blobs Server')
- ax.set_xticks(ind + width)
- ax.set_xticklabels(tuple(labels))
+ ax.set_xticks(ind + (1.5 * width))
+ ax.set_xticklabels(tuple(graphs))
ax.legend(
(rects1[0], rects2[0], rects3[0], rects4[0]),
- ('1 process', '2 processes', '4 processes', '8 processes'))
- ax.grid()
+ ('1 process', '2 processes', '3 processes', '4 processes'))
+ ax.grid(True)
plt.savefig('blobs-in-parallel.png')
plt.show()
diff --git a/blobs-multiprocess/makefile b/blobs-multiprocess/makefile
index 4a8cbaa..a58bb60 100644
--- a/blobs-multiprocess/makefile
+++ b/blobs-multiprocess/makefile
@@ -1,44 +1,78 @@
-DIR = /tmp/blobs
-PORT = 8000
-URI = http://127.0.0.1:8000/blobs/user
-UUID = $(shell uuidgen)
-PROCS ?= 4
+DIR = /tmp/blobs
+PORT = 8000
+BASE_URI = http://127.0.0.1:8000
+BLOBS_URI = $(BASE_URI)/blobs/user
+UUID = $(shell uuidgen)
+PROCS ?= 4
+SIZE ?= 56
all: multiproc
-server: killall
+server:
python blobs-server.py $(DIR) $(PORT)
-multiproc:
+multiproc: roundrobin
python multiproc.py --procs $(PROCS)
-roundrobin: killall
+roundrobin: kill-haproxy
/usr/sbin/haproxy -D -f haproxy/roundrobin-$(PROCS).cfg
-killall:
+kill-haproxy:
-killall -9 haproxy
+kill-server:
+ pid=$$(ps aux | grep python\ blobs-server.py | grep -v grep | awk "{print \$$2}"); \
+ kill -9 $${pid}
+
data:
- dd if=/dev/urandom of=/tmp/data bs=1024 count=100
+ dd if=/dev/urandom of=/tmp/data bs=1024 count=$(SIZE)
list:
- curl -X GET $(URI)/
+ curl -X GET $(BLOBS_URI)/
-put:
- curl -X PUT $(URI)/$(UUID) --data-binary @/tmp/data
+put: data
+ curl -X PUT $(BLOBS_URI)/$(UUID) --data-binary @/tmp/data
get:
UUID=$(UUID); \
- curl -X PUT $(URI)/$${UUID} --data-binary @/tmp/data; \
- curl -X GET $(URI)/$${UUID} > /dev/null
+ curl -X PUT $(BLOBS_URI)/$${UUID} --data-binary @/tmp/data; \
+ curl -X GET $(BLOBS_URI)/$${UUID} > /dev/null
delete:
UUID=$(UUID); \
- curl -X PUT $(URI)/$${UUID} --data-binary @/tmp/data; \
- curl -X DELETE $(URI)/$${UUID}
+ curl -X PUT $(BLOBS_URI)/$${UUID} --data-binary @/tmp/data; \
+ curl -X DELETE $(BLOBS_URI)/$${UUID}
+
+stress-baseline-ab: clean
+ ab -c 10 -n 1000 http://127.0.0.1:8000/
+
+stress-baseline: clean
+ siege --concurrent=50 -t 5s http://127.0.0.1:8000/
+
+stress-put: clean
+ #ab -c 10 -n 1000 -T /tmp/data $(BLOBS_URI)/$(UUID)
+ ab -c 10 -n 1000 -T /tmp/data $(BLOBS_URI)/$(UUID)
+
+stress-get:
+ @ab -c 10 -n 1000 -q $(BASE_URI)/ | grep ^Requests | awk '{print $$4}'
+
+ab-get:
+ @ab -c 10 -n 1000 -q -m GET $(URI) | grep ^Requests | awk '{print $$4}'
+
+ab-put:
+ @ab -c 10 -n 1000 -q -u /tmp/data $(URI) | grep ^Requests | awk '{print $$4}'
+
+ab-flag:
+ @ab -c 10 -n 1000 -q -p /tmp/flag $(URI) | grep ^Requests | awk '{print $$4}'
+
+ab-delete:
+ @ab -c 10 -n 1000 -q -m DELETE $(URI) | grep ^Requests | awk '{print $$4}'
+
+clean:
+ rm -rf /tmp/blobs/*
-put-ab:
- ab -c 10 -n 1000 -T /tmp/data $(URI)/$(UUID)
+flag:
+ echo '["PROCESSING"]' > /tmp/flag
-.PHONY: server multiproc roundrobin killall
+.PHONY: server multiproc roundrobin kill-server kill-haproxy
diff --git a/blobs-multiprocess/request.py b/blobs-multiprocess/request.py
index 9f35ca0..e533308 100755
--- a/blobs-multiprocess/request.py
+++ b/blobs-multiprocess/request.py
@@ -11,8 +11,8 @@ from uuid import uuid4
BASE_URI = 'http://127.0.0.1:8000/'
-BLOBS_URI = urljoin(BASE_URI,
- 'blobs/{}/'.format(time.strftime('%Y-%m-%d_%H-%M-%s')))
+BLOBS_URI = urljoin(BASE_URI, 'blobs/user/')
+# 'blobs/{}/'.format(time.strftime('%Y-%m-%d_%H-%M-%s')))
CONCURRENT = 10
@@ -45,9 +45,9 @@ def parse_args():
return args
-def _finished(_, start):
+def _finished(_, start, amount):
end = time.time()
- print(end - start)
+ print(float(amount) / (end - start))
reactor.stop()
@@ -56,12 +56,12 @@ def _error(failure):
reactor.stop()
-def main(generator):
+def main(generator, amount):
cooperator = task.Cooperator()
cooptask = cooperator.cooperate(generator)
start = time.time()
d = cooptask.whenDone()
- d.addCallback(_finished, start)
+ d.addCallback(_finished, start, amount)
d.addErrback(_error)
return d
@@ -86,8 +86,6 @@ def requests_generator(args):
deferreds = []
for i in xrange(args.amount):
if args.baseline:
- import pdb
- pdb.set_trace()
d = _client.get(BASE_URI)
elif args.list:
@@ -116,5 +114,5 @@ def requests_generator(args):
if __name__ == "__main__":
args = parse_args()
generator = requests_generator(args)
- d = main(generator)
+ d = main(generator, args.amount)
reactor.run()
diff --git a/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png b/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png
deleted file mode 100644
index db3fd96..0000000
--- a/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png
+++ /dev/null
Binary files differ
diff --git a/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt b/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt
deleted file mode 100644
index 80d16ae..0000000
--- a/blobs-multiprocess/results/2017-01-04_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-1 baseline 1000 10 1.70170302391
-1 list 1000 10 1.86631264687
-1 put 1000 10 2.04504818916
-1 get 1000 10 5.2823679924
-1 flag 1000 10 3.88802418709
-1 delete 1000 10 3.07739658356
-2 baseline 1000 10 1.69806017876
-2 list 1000 10 3.11238617897
-2 put 1000 10 2.83830742836
-2 get 1000 10 3.40557880402
-2 flag 1000 10 3.2692761898
-2 delete 1000 10 3.34825959206
-4 baseline 1000 10 2.49910435677
-4 list 1000 10 2.48401441574
-4 put 1000 10 2.3237077713
-4 get 1000 10 3.88459482193
-4 flag 1000 10 3.63829479218
-4 delete 1000 10 3.17096538544
-8 baseline 1000 10 2.12282576561
-8 list 1000 10 2.49229278564
-8 put 1000 10 2.69512839317
-8 get 1000 10 3.47697739601
-8 flag 1000 10 3.35881881714
-8 delete 1000 10 3.29797801971
diff --git a/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png b/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png
deleted file mode 100644
index 139b9cc..0000000
--- a/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.png
+++ /dev/null
Binary files differ
diff --git a/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt b/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt
deleted file mode 100644
index 29dc773..0000000
--- a/blobs-multiprocess/results/2017-01-05_Intel-Core-i7-4600U@2.10GHz_8GB-RAM_SATA-II-SSD-LITEONIT-LGT-256M6G.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-1 baseline 1000 10 1.65788397789
-1 list 1000 10 1.76658239365
-1 put 1000 10 2.16625041962
-1 get 1000 10 4.93044900894
-1 flag 1000 10 3.89305019379
-1 delete 1000 10 2.97089977264
-2 baseline 1000 10 1.60334076881
-2 list 1000 10 2.71356620789
-2 put 1000 10 3.23587818146
-2 get 1000 10 3.38332500458
-2 flag 1000 10 3.25708303452
-2 delete 1000 10 3.03945021629
-4 baseline 1000 10 2.60279417038
-4 list 1000 10 2.11859984398
-4 put 1000 10 2.2915845871
-4 get 1000 10 3.48964958191
-4 flag 1000 10 3.69795999527
-4 delete 1000 10 3.31933698654
-8 baseline 1000 10 2.12685017586
-8 list 1000 10 2.35639958382
-8 put 1000 10 2.58642120361
-8 get 1000 10 3.74429321289
-8 flag 1000 10 3.53779459
-8 delete 1000 10 3.292395401
diff --git a/blobs-multiprocess/results/blobs-in-parallel-1.png b/blobs-multiprocess/results/blobs-in-parallel-1.png
deleted file mode 100644
index c23a635..0000000
--- a/blobs-multiprocess/results/blobs-in-parallel-1.png
+++ /dev/null
Binary files differ
diff --git a/blobs-multiprocess/run-test.sh b/blobs-multiprocess/run-test.sh
index eab6aaa..dae5579 100755
--- a/blobs-multiprocess/run-test.sh
+++ b/blobs-multiprocess/run-test.sh
@@ -45,42 +45,120 @@ start_multiproc() {
}
-get_best() {
- statement=$*
- result=$(python -m timeit -n 1 -r 5 -s "import os" "os.system('${statement}')")
- best=$(echo $result | sed -e s/.\*best\ of\ 5:\ // -e s/per\ loop//)
- echo $best
+ab-get() {
+ action=${1}
+ procs=${2}
+ amount=${3}
+ size=${4}
+ statement="make stress-get UUID=blob"
+ python -c "import timeit; t = timeit.timeit('import os; os.system(\'${statement} > /dev/null\');', number=5); print t / 5"
+ echo "${procs} ${action} ${amount} ${size} ${time}"
}
-get_mean() {
- statement=$*
- python -c "import timeit; t = timeit.timeit('import os; os.system(\'./${statement} > /dev/null\');', number=5); print t / 5"
+ab-baseline() {
+ make ab-get URI=http://127.0.0.1:8000/
}
-request() {
- action=${1}
- procs=${2}
- amount=${3}
- size=${4}
- best=$(get_mean ./request.py --${action} ${amount} ${size})
- echo "${procs} ${action} ${amount} ${size} ${best}"
+ab-put() {
+ port=${1}
+ if [ -z "${port}" ]; then port=8000; fi
+ make ab-put URI=http://127.0.0.1:${port}/blobs/user/blob_id
+}
+
+
+ab-get() {
+ make ab-get URI=http://127.0.0.1:8000/blobs/user/blob_id
+}
+
+
+ab-list() {
+ make ab-get URI=http://127.0.0.1:8000/blobs/user/
+}
+
+
+ab-flag() {
+ make ab-flag URI=http://127.0.0.1:8000/blobs/user/blob_id
+}
+
+
+ab-delete() {
+ make ab-delete URI=http://127.0.0.1:8000/blobs/user/blob_id
}
run_test() {
- for procs in 1 2 4 8; do
+ echo "" > results.txt
+ #for procs in 1 2 4 8; do
+ for procs in 1 2 3 4; do
+ echo ":: Running tests for ${procs} proceesses..."
+
+ # setup
+ make clean
+ make data SIZE=56
start_multiproc ${procs}
- for action in baseline list put get flag delete; do
- #for amountsize in "10 1000" "100 100" "1000 10"; do
- for amountsize in "1000 10"; do
- rm -rf /tmp/blobs/*
- request ${action} ${procs} ${amountsize} >> results.txt
- done
+ sleep 2
+
+ echo ":::: Running baseline test..."
+ result="${procs} baseline $(ab-baseline)"
+ echo ${result}
+ echo ${result} >> results.txt
+ sleep 2
+ #read temp
+
+ echo ":::: Running put test..."
+ result="${procs} put $(ab-put)"
+ echo ${result}
+ echo ${result} >> results.txt
+ sleep 2
+ #read temp
+
+ # setup tests that depend on existence of blobs
+ kill_multiproc
+ make clean
+ make kill-haproxy
+ for port in 8001 8002 8003 8004; do
+ echo ":::::: creating blobs prefixed with ${port}-..."
+ make server PORT=${port} > /dev/null &!
+ sleep 1
+ ab-put ${port}
+ #read temp
+ make kill-server
done
+ sleep 2
+
+ echo ":::: Running list test..."
+ start_multiproc ${procs}
+ result="${procs} list $(ab-list)"
+ echo ${result}
+ echo ${result} >> results.txt
+ sleep 2
+
+ echo ":::: Running flag test..."
+ make flag
+ result="${procs} flag $(ab-flag)"
+ echo ${result}
+ echo ${result} >> results.txt
+ sleep 2
+
+ echo ":::: Running get test..."
+ kill_multiproc
+ start_multiproc ${procs}
+ result="${procs} get $(ab-get)"
+ echo ${result}
+ echo ${result} >> results.txt
+ sleep 2
+
+ echo ":::: Running delete test..."
+ kill_multiproc
+ start_multiproc ${procs}
+ result="${procs} delete $(ab-delete)"
+ echo ${result}
+ echo ${result} >> results.txt
kill_multiproc
done
}
+
run_test