From d7137cb56a1464f99929ec5f0def8d84637c2e40 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Thu, 23 Dec 2021 01:44:25 +0200 Subject: [PATCH] [benchmarks] Add support for HAProxy comparison and `hey` benchmarker. --- examples/haproxy.conf | 23 ++++++++++++ examples/nginx.conf | 2 +- scripts/benchmark.z-run | 77 +++++++++++++++++++++++++++++++++++++++++ scripts/tools.z-run | 19 ++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 examples/haproxy.conf diff --git a/examples/haproxy.conf b/examples/haproxy.conf new file mode 100644 index 0000000..88ead1e --- /dev/null +++ b/examples/haproxy.conf @@ -0,0 +1,23 @@ + + +global + nbthread 2 + + +defaults + timeout client 6s + timeout server 6s + timeout connect 6s + timeout tarpit 1s + + +frontend http + mode http + bind ipv4@127.9.185.194:8080 + + # NOTE: Equivalent to `kawipiko`'s `--dummy-empty` + # http-request return + + # NOTE: Equivalent to `kawipiko`'s `--dummy` + http-request return status 200 content-type "text/plain; charset=utf-8" string "hello world!\n" hdr "Content-Encoding" "identity" hdr "Cache-Control" "no-store, max-age=0" + diff --git a/examples/nginx.conf b/examples/nginx.conf index 1243e5c..6544810 100644 --- a/examples/nginx.conf +++ b/examples/nginx.conf @@ -20,7 +20,7 @@ http { server { - listen 127.0.0.1:8080 default_server bind backlog=65536; + listen 127.9.185.194:8080 default_server bind backlog=65536; server_name nginx; server_name_in_redirect off; diff --git a/scripts/benchmark.z-run b/scripts/benchmark.z-run index 6ec92de..6caff01 100644 --- a/scripts/benchmark.z-run +++ b/scripts/benchmark.z-run @@ -126,6 +126,22 @@ :: benchmark / h2load / http3 / 1 :: exec -- "${ZRUN[@]}" ':: benchmark / h2load / http3' "${@}" --threads 1 --clients 1 +:: benchmark / hey / http / 16384 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 16384 -t 6s +:: benchmark / hey / http / 4096 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 4096 +:: benchmark / hey / http / 2048 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 2048 +:: benchmark / hey / http / 1024 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 1024 +:: benchmark / hey / http / 512 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 512 +:: benchmark / hey / http / 256 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 256 +:: benchmark / hey / http / 128 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 128 +:: benchmark / hey / http / 64 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 64 +:: benchmark / hey / http / 32 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 32 +:: benchmark / hey / http / 16 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 2 -c 16 +:: benchmark / hey / http / 8 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 1 -c 8 +:: benchmark / hey / http / 4 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 1 -c 4 +:: benchmark / hey / http / 2 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 1 -c 2 +:: benchmark / hey / http / 1 :: exec -- "${ZRUN[@]}" ':: benchmark / hey / http' "${@}" -cpus 1 -c 1 + + --<< benchmark / server @@ -315,6 +331,26 @@ +<< benchmark / alternatives / haproxy + exec -- \ + sudo -u root -n -E -P -- \ + taskset -c 0,1 \ + nice -n -19 -- \ + ionice -c 2 -n 0 -- \ + chrt -r 10 \ + prlimit -n262144 -- \ + sudo -u "${USER}" -n -E -P -- \ + env -i -- \ + ./.bin/haproxy \ + -db \ + -f ./examples/haproxy.conf \ + "${@}" \ + # +!! + + + + @@ -437,3 +473,44 @@ # !! + + + +<< benchmark / hey / http + exec -- "${ZRUN[@]}" ':: benchmark / hey' http 127.9.185.194:8080 "${@}" +!! + +<< benchmark / hey / https + exec -- "${ZRUN[@]}" ':: benchmark / hey' https 127.9.185.194:8443 "${@}" +!! + +--<< benchmark / hey + test "${#}" -ge 2 + _url_base="${1}://${2}" + shift -- 2 + if test "${#}" -ge 1 ; then + if test "${1:0:1}" != '-' ; then + _path="${1}" + _path="${_path#/}" + shift -- 1 + else + _path='' + fi + else + _path='' + fi + exec -- \ + sudo -u root -n -E -P -- \ + taskset -c 2,3 \ + nice -n -19 -- \ + ionice -c 2 -n 0 -- \ + chrt -r 10 \ + prlimit -n262144 -- \ + sudo -u "${USER}" -n -E -P -- \ + "${ZRUN[@]}" ':: tools / hey' \ + "${@}" \ + -- \ + "${_url_base}/${_path}" \ + # +!! + diff --git a/scripts/tools.z-run b/scripts/tools.z-run index 5ac56bb..48a54b3 100644 --- a/scripts/tools.z-run +++ b/scripts/tools.z-run @@ -44,6 +44,25 @@ +<< tools / hey + test -f ./.bin/hey + test -x ./.bin/hey + test "${#}" -ge 1 + exec -- \ + env -i -- \ + ./.bin/nodaemon \ + ./.bin/hey \ + -cpus 1 \ + -c 1 \ + -z 30s \ + -t 1 \ + "${@}" \ + # +!! + + + + << tools / nghttp test -f ./.bin/nghttp test -x ./.bin/nghttp