aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/httpd.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-05-15 17:47:22 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-05-15 17:51:06 +0200
commit7da91858ce7959f102a04bca2b2fcfd418e5a7a9 (patch)
tree19abc82074f001f85729ff00e8ae6ec0bbaad5d3 /src/benchmarks/httpd.py
parentf63ac8afd8110d3fcea9dd1f7eb2b8175f4ac306 (diff)
downloadallocbench-7da91858ce7959f102a04bca2b2fcfd418e5a7a9.tar.gz
allocbench-7da91858ce7959f102a04bca2b2fcfd418e5a7a9.zip
introduce server concept to Benchmark
A benchmark object can specify a list of cmds to execute as "servers" in the member attribute server_cmds. Servers are started and terminated through Popen objects. This requires the server cmds to not daemonize so the server can be terminated through the Popen object. For each started server cmd a shutdown function is registered with atexit to terminate all servers even if a exception occurs. Use the new server concept in httpd and mysql benchmarks
Diffstat (limited to 'src/benchmarks/httpd.py')
-rw-r--r--src/benchmarks/httpd.py70
1 files changed, 18 insertions, 52 deletions
diff --git a/src/benchmarks/httpd.py b/src/benchmarks/httpd.py
index de59d4e..980a6cc 100644
--- a/src/benchmarks/httpd.py
+++ b/src/benchmarks/httpd.py
@@ -1,4 +1,3 @@
-import atexit
import matplotlib.pyplot as plt
import numpy as np
import re
@@ -8,55 +7,26 @@ from subprocess import PIPE
import sys
from time import sleep
-from src.globalvars import builddir
from src.benchmark import Benchmark
from src.util import *
-server_cmd = "{} -c {}/benchmarks/httpd/nginx/nginx.conf".format(shutil.which("nginx"), builddir).split()
-
class Benchmark_HTTPD(Benchmark):
def __init__(self):
self.name = "httpd"
self.descrition = """TODO"""
- self.args = {"nthreads": Benchmark.scale_threads_for_cpus(2)}
- self.cmd = "ab -n 10000 -c {nthreads} localhost:8080/index.html"
+ self.args = {"nthreads": Benchmark.scale_threads_for_cpus(2),
+ "site": ["index.html", "index.php"]}
+ self.cmd = "ab -n 100 -c {nthreads} localhost:8080/{site}"
self.measure_cmd = ""
- self.server_benchmark = True
+ self.server_cmds = ["nginx -c {builddir}/benchmarks/httpd/etc/nginx/nginx.conf",
+ "php-fpm -c {builddir}/benchmarks/httpd/etc/php/php.ini -y {builddir}/benchmarks/httpd/etc/php/php-fpm.conf -F"]
self.requirements = ["nginx", "ab"]
- atexit.register(self.terminate_server)
-
super().__init__()
- def terminate_server(self):
- # check if nginx is running
- if os.path.isfile(os.path.join(builddir, "benchmarks", self.name, "nginx", "nginx.pid")):
- ret = subprocess.run(server_cmd + ["-s", "stop"], stdout=PIPE,
- stderr=PIPE, universal_newlines=True)
-
- if ret.returncode != 0:
- print_debug("Stdout:", ret.stdout)
- print_debug("Stderr:", ret.stderr)
- raise Exception("Stopping {} failed with {}".format(server_cmd[0], ret.returncode))
-
- def preallocator_hook(self, allocator, run, env, verbose):
- actual_cmd = allocator[1]["cmd_prefix"].split() + server_cmd
- print_info("Starting server with:", actual_cmd)
-
- ret = subprocess.run(actual_cmd, stdout=PIPE, stderr=PIPE, env=env,
- universal_newlines=True)
- if ret.returncode != 0:
- print_debug("Stdout:", ret.stdout)
- print_debug("Stderr:", ret.stderr)
- raise Exception("Starting {} for {} failed with {}".format(server_cmd[0], allocator[0], ret.returncode))
-
-
- def postallocator_hook(self, allocator, run, verbose):
- self.terminate_server()
-
def process_output(self, result, stdout, stderr, allocator, perm, verbose):
result["time"] = re.search("Time taken for tests:\s*(\d*\.\d*) seconds", stdout).group(1)
result["requests"] = re.search("Requests per second:\s*(\d*\.\d*) .*", stdout).group(1)
@@ -74,33 +44,29 @@ class Benchmark_HTTPD(Benchmark):
self.calc_desc_statistics()
# linear plot
- self.plot_single_arg("{requests}",
+ self.plot_fixed_arg("{requests}",
xlabel='"threads"',
ylabel='"requests/s"',
- title='"ab -n 10000 -c threads"')
+ autoticks=False,
+ filepostfix="requests",
+ title='"ab -n 10000 -c " + str(perm.nthreads)')
# linear plot
ref_alloc = list(allocators)[0]
- self.plot_single_arg("{requests}",
+ self.plot_fixed_arg("{requests}",
xlabel='"threads"',
ylabel='"requests/s scaled at " + scale',
- title='"ab -n 10000 -c threads (normalized)"',
- filepostfix="norm",
+ title='"ab -n 10000 -c " + str(perm.nthreads) + " (normalized)"',
+ filepostfix="requests.norm",
+ autoticks=False,
scale=ref_alloc)
# bar plot
- self.barplot_single_arg("{requests}",
- xlabel='"threads"',
- ylabel='"requests/s"',
- filepostfix="b",
- title='"ab -n 10000 -c threads"')
+ # self.barplot_fixed_arg("{requests}",
+ # xlabel='"threads"',
+ # ylabel='"requests/s"',
+ # filepostfix="b",
+ # title='"ab -n 10000 -c threads"')
- # bar plot
- self.barplot_single_arg("{requests}",
- xlabel='"threads"',
- ylabel='"requests/s scaled at " + scale',
- title='"ab -n 10000 -c threads (normalized)"',
- filepostfix="norm.b.",
- scale=ref_alloc)
httpd = Benchmark_HTTPD()