From 1312019c1bd692ad1c8360174d691c85d5718229 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Thu, 23 Dec 2021 17:48:41 +0200 Subject: [PATCH] [benchmarks] Add initial real NGinx benchmarking support. --- examples/{ => nginx}/nginx.conf | 49 ++++++++++++++-------------- scripts/benchmark.z-run | 57 +++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 37 deletions(-) rename examples/{ => nginx}/nginx.conf (72%) diff --git a/examples/nginx.conf b/examples/nginx/nginx.conf similarity index 72% rename from examples/nginx.conf rename to examples/nginx/nginx.conf index 54d32fc..b874612 100644 --- a/examples/nginx.conf +++ b/examples/nginx/nginx.conf @@ -1,13 +1,22 @@ +master_process off; +worker_processes 0; +worker_rlimit_nofile 131072; + +events { + use epoll; + worker_connections 16640; + accept_mutex off; + multi_accept off; +} + + http { - root @{nginx}/store; - index index.html index.txt; autoindex off; - include /dev/null; default_type application/octet-stream; gzip off; @@ -17,22 +26,25 @@ http { gzip_proxied any; gzip_types *; + server { - listen @{bind_ip}:@{bind_port} default_server bind backlog=65536; + listen @{nginx_bind_http} bind reuseport deferred backlog=65536; server_name nginx; server_tokens off; server_name_in_redirect off; port_in_redirect off; + keepalive_disable none; keepalive_requests 262144; keepalive_timeout 60s; tcp_nodelay off; tcp_nopush off; + sendfile off; directio off; aio off; @@ -51,9 +63,7 @@ http { limit_except GET HEAD { deny all; } - } - } @@ -61,27 +71,18 @@ http { access_log off; log_not_found on; - client_body_temp_path @{nginx}/empty; - proxy_temp_path @{nginx}/empty; - fastcgi_temp_path @{nginx}/empty; - uwsgi_temp_path @{nginx}/empty; - scgi_temp_path @{nginx}/empty; + root @{nginx_root}; + + client_body_temp_path @{nginx_empty}; + proxy_temp_path @{nginx_empty}; + fastcgi_temp_path @{nginx_empty}; + uwsgi_temp_path @{nginx_empty}; + scgi_temp_path @{nginx_empty}; } -worker_processes 2; -worker_rlimit_nofile 131072; -working_directory @{nginx}/empty; - +working_directory @{nginx_empty}; error_log /dev/stderr notice; -pid @{nginx}/pid; +pid @{nginx_pid}; daemon off; - -events { - use epoll; - worker_connections 16640; - accept_mutex off; - multi_accept off; -} - diff --git a/scripts/benchmark.z-run b/scripts/benchmark.z-run index bca0377..6142d04 100644 --- a/scripts/benchmark.z-run +++ b/scripts/benchmark.z-run @@ -176,19 +176,7 @@ test "${#}" -ge 1 _mode="${1}" shift -- 1 - if test "${#}" -ge 1 ; then - if test "${1:0:1}" != '-' ; then - _archive="${1}" - shift -- 1 - else - _archive='' - fi - else - _archive='' - fi - if test -z "${_archive}" ; then - _archive=./examples/hello-world.cdb - fi + _archive=./examples/hello-world.cdb _arguments=() case "${_mode}" in ( http-all ) @@ -352,6 +340,49 @@ + + + + +:: benchmark / nginx / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / nginx' 1 "${@}" +:: benchmark / nginx / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / nginx' 2 "${@}" + +<< benchmark / nginx + test "${#}" -ge 1 + _count="${1}" + shift -- 1 + _archive=./examples/hello-world + sed \ + -r \ + -e 's#@\{nginx_root\}#'"${_archive}"'#g' \ + -e 's#@\{nginx_bind_http\}#127.9.185.194:8080#g' \ + -e 's#@\{nginx_empty\}#/var/lib/empty#g' \ + -e 's#@\{nginx_pid\}#/tmp/nginx.pid#g' \ + < ./examples/nginx/nginx.conf \ + >| ./examples/nginx/nginx.conf.tmp \ + # + _arguments=( + -c ./examples/nginx/nginx.conf.tmp + -e /dev/stderr + -p . + ) + exec -- \ + "${ZRUN[@]}" ':: benchmark / execute / multiple' "${_count}" \ + "${ZRUN[@]}" ':: benchmark / execute / server' \ + noenvironment \ + ./.bin/nginx \ + "${_arguments[@]}" \ + "${@}" \ + # +!! + + + + + + + + :: benchmark / dummy / fasthttp / 1x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 1 "${@}" :: benchmark / dummy / fasthttp / 1x2 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 1 2 "${@}" :: benchmark / dummy / fasthttp / 2x1 :: exec -- "${ZRUN[@]}" ':: benchmark / dummy / fasthttp' 2 1 "${@}"