diff --git a/daemon/nginx-server b/daemon/nginx-server index f3cad9b683ce80d511ba333fe6b481888c8edee5..7ebee02af745fabf04e9091f29dccc26241e5c23 100755 --- a/daemon/nginx-server +++ b/daemon/nginx-server @@ -1,5 +1,7 @@ #!/bin/sh # Job yaml can send below ENVIRONMENT VARIABLES to me +# - workers +# - bench_type # - nics # - nics_ips # - core_nums @@ -17,6 +19,8 @@ : "${protocol:=https}" # http or https : "${alive_type:=short}" # short or long +workers=${workers:-4} +bench_type="${bench_type:-wrk} nics=(${nics//,/ }) nics_ips=(${nics_ips//,/ }) [ -n "$BENCHMARK_ROOT" ] || BENCHMARK_ROOT=/lkp/benchmarks @@ -150,7 +154,31 @@ assign_core_ranges() fi } -main() +create_key() +{ + cd $BENCHMARK_ROOT/nginx-server/ + ${WRK_SRC_DIR}/create_key.sh +} + +modify_conf() +{ + sed -i "s#{{WORKERS}}#${workers}#g" "${WRK_SRC_DIR}/nginx_4.conf" + sed -i "s#{{BENCHMARK_ROOT}}#${BENCHMARK_ROOT}#g" "${WRK_SRC_DIR}/nginx_4.conf" + cp "${WRK_SRC_DIR}/nginx_4.conf" $BENCHMARK_ROOT/nginx-server/ +} +} + +wrk_test() +{ + WRK_SRC_DIR="${LKP_SRC}/programs/wrk" + create_key + modify_conf + $BENCHMARK_ROOT/nginx-server/sbin/nginx \ + -c $BENCHMARK_ROOT/nginx-server/nginx_4.conf \ + -e $BENCHMARK_ROOT/nginx-server/logs/error.log +} + +main_test() { local core_ranges local nginx_path="$BENCHMARK_ROOT/nginx-server/sbin/nginx" @@ -158,9 +186,10 @@ main() check_nginx_install prepare - assign_core_ranges - + assign_core_ranges + index=0 + for core_range in $core_ranges do local nic=${nics[$index]} @@ -172,4 +201,8 @@ main() done } -main +if [[ "${bench_type}" == "wrk" ]]; then + wrk_test +elif [[ "${bench_type}" == "nginx" ]]; then + main_test +fi \ No newline at end of file diff --git a/programs/wrk/PKGBUILD b/programs/wrk/PKGBUILD new file mode 100644 index 0000000000000000000000000000000000000000..28357f42c27cb0829d5e9ad335bd575a14641eac --- /dev/null +++ b/programs/wrk/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=nginx +pkgver=1.22 +pkgrel=1 +arch=('aarch64' 'x86_64') +url="https://nginx.org/ru/" +license=('GPL') +makedepends_debian_11=(unzip tar gcc gcc-c++ make libatomic libtool zlib zlib-devel pcre pcre-devel perl-devel perl-ExtUtils-Embed openssl openssl-devel net-tools git) +source=( + "https://repo.huaweicloud.com/nginx/${pkgname}-$pkgver.$pkgrel.tar.gz" + "https://github.com/wg/wrk/archive/refs/tags/4.2.0.tar.gz") +md5sums=('8296d957561aeed0261d9be4d3decaec' 'SKIP' ) + +build() +{ + cd "$srcdir"/wrk-4.2.0 + make -j + + mkdir -p /lkp/benchmarks/${pkgname}-server/logs/ + cd "$srcdir/$pkgname-$pkgver.$pkgrel" + ./configure \ + --prefix="/lkp/benchmarks/nginx-server/" \ + --with-http_ssl_module \ + --without-http_gzip_module \ + --error-log-path="/lkp/benchmarks/nginx-server/logs/error.log" \ + --http-log-path="/lkp/benchmarks/nginx-server/logs/access.log" + make -j +} + +package() +{ + cd "$srcdir/$pkgname-$pkgver.$pkgrel" + make DESTDIR="${pkgdir}" install + + mkdir -p ${pkgdir}/lkp/benchmarks/wrk-bench/ + cp "${srcdir}"/wrk-4.2.0/wrk ${pkgdir}/lkp/benchmarks/wrk-bench/ +} \ No newline at end of file diff --git a/programs/wrk/create_key.sh b/programs/wrk/create_key.sh new file mode 100644 index 0000000000000000000000000000000000000000..63b854c420a53d37b7c1e163f9211d169d03f7ce --- /dev/null +++ b/programs/wrk/create_key.sh @@ -0,0 +1,32 @@ +#!/usr/bin/expect +set timeout 1 +spawn openssl genrsa -des3 -out server_2048.key 2048 +expect "Enter pass phrase for server_2048.key:" +send "123456\r" +expect "Verifying - Enter pass phrase for server_2048.key:" +send "123456\r" +expect eof + +spawn openssl rsa -in server_2048.key -out server_2048.key +expect "Enter pass phrase for server_2048.key:" +send "123456\r" +expect eof + +spawn openssl req -new -key server_2048.key -out server_2048.csr +expect "Country Name (2 letter code) \[AU\]:" +send "CN\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +send "\r" +expect eof + +spawn openssl rsa -in server_2048.key -out server_2048.key +expect eof + +spawn openssl x509 -req -days 365 -in server_2048.csr -signkey server_2048.key -out server_2048.crt +expect eof \ No newline at end of file diff --git a/programs/wrk/jobs/wrk.yaml b/programs/wrk/jobs/wrk.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3d8bc4ad3f49f3fe95c9632a21aa17b3d2cad395 --- /dev/null +++ b/programs/wrk/jobs/wrk.yaml @@ -0,0 +1,40 @@ +suite: wrk +category: benchmark +cluster: taishan200-2280-2s48p-256g +cluster_spec: + node: + taishan200-2280-2s48p-256g--a16: + roles: + - server + taishan200-2280-2s48p-256g--a18: + roles: + - client + +set_nic_irq_affinity: 1 + +#if role server: +daemon.nginx-server: + if-role: server + workers: + - 4 + bench_type: + - wrk +#if role client: +program.wrk: + if-role: client + concurrent: + - 2000 + duration: + - 60s + threads: + - 20 + protocols: + - http + - https + alive_type: + - close + - keep-alive + timeout: + - 5s + testIp: + - testip \ No newline at end of file diff --git a/programs/wrk/meta.yaml b/programs/wrk/meta.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f2d832416cc8fd8f252c70496177eae81951656b --- /dev/null +++ b/programs/wrk/meta.yaml @@ -0,0 +1,40 @@ +metadata: + name: wrk + summary: . + +type: client +depends: + openeuler@22.03: + - tar + - gcc + - gcc-c++ + - make + - libtool + - zlib + - zlib-devel + - pcre + - pcre-devel + - perl + - openssl + - openssl-devel + - perl-ExtUtils-Embed + - net-tools + - git + - expect + - jq + PKGBUILD: + - wrk + +params: + workers: + bench_type: + concurrent: + duration: + threads: + protocols: + alive_type: + layency: + timeout: + +results: + diff --git a/programs/wrk/nginx_4.conf b/programs/wrk/nginx_4.conf new file mode 100644 index 0000000000000000000000000000000000000000..22f7b59151f3eacfb246601fae82d0d2690d0c9b --- /dev/null +++ b/programs/wrk/nginx_4.conf @@ -0,0 +1,48 @@ +user root; +worker_processes {{WORKERS}}; +worker_cpu_affinity auto; +worker_rlimit_nofile 1024000; +events { + use epoll; + worker_connections 32768; + accept_mutex off; + multi_accept off; +} +http{ + include {{BENCHMARK_ROOT}}/nginx-server/conf/mime.types; + default_type application/octet-stream; + access_log off; + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + + open_file_cache max=102400 inactive=40s; + open_file_cache_valid 50s; + open_file_cache_min_uses 1; + open_file_cache_errors on; + server { + listen 10000; + location / { + root {{BENCHMARK_ROOT}}/nginx-server/html; + index index.html index.gtm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root htmls; + } + } + server { + listen 20000 ssl; + server_name localhost; + ssl_certificate {{BENCHMARK_ROOT}}/nginx-server/server_2048.crt; + ssl_certificate_key {{BENCHMARK_ROOT}}/nginx-server/server_2048.key; + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 5m; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + location / { + root {{BENCHMARK_ROOT}}/nginx-server/html; + index index.html index.htm; + } + } +} \ No newline at end of file diff --git a/programs/wrk/parse b/programs/wrk/parse new file mode 100644 index 0000000000000000000000000000000000000000..49ffd26f77577f88dec23fb28aa250dbe8340575 --- /dev/null +++ b/programs/wrk/parse @@ -0,0 +1 @@ +#!/usr/bin/env ruby diff --git a/programs/wrk/run b/programs/wrk/run new file mode 100644 index 0000000000000000000000000000000000000000..f3fb7f6a02658e837139917a19bd7e30aded0dc5 --- /dev/null +++ b/programs/wrk/run @@ -0,0 +1,60 @@ +#!/bin/sh +# Job yaml can send below ENVIRONMENT VARIABLES to me +# concurrent: +# duration: +# threads: +# protocols: +# alive_type: +# timeout: +# testIp: +# . "$LKP_SRC"/lib/reproduce-log.sh +# . "$LKP_SRC"/lib/numactl.sh + +concurrent=${concurrent:-"2000"} +duration=${duration:-"60s"} +threads=${threads:-"20"} +timeout=${timeout:-"5s"} + +ulimit -n 2048 + +handle_data() +{ + echo http_short + cat http_close.log|grep Requests/sec | awk -F ' ' {'print'} + echo http_long + cat http_keep-alive.log|grep Requests/sec | awk -F ' ' {'print'} + echo https_short + cat https_close.log|grep Requests/sec | awk -F ' ' {'print'} + echo https_long + cat https_keep-alive.log|grep Requests/sec | awk -F ' ' {'print'} +} + +[ -n "$direct_ips" ] && server_ip=${direct_ips} + +for i in `seq 1 3`; do + echo "The ${i}-th iteration test" + for protocol in ${protocols[@]}; do + if [ "$protocol" = "http" ]; then + PORT=10000 + elif [ "$protocol" = "https" ]; then + PORT=20000 + else + echo "Unsupported protocol: $protocol" + exit 1 + fi + for alive in ${alive_type[@]}; do + echo 3 > /proc/sys/vm/drop_caches + local cmd=("$BENCHMARK_ROOT/wrk-bench/wrk" + -c "${concurrent}" + -d "${duration}" + -t "${threads}" + -H "Connection: ${alive}" + --timeout "${timeout}" + "${protocol}://${server_ip}:${PORT}/index.html") + echo "Running: ${cmd[*]}" + "${cmd[@]}" + done + done +done + +handle_data \ No newline at end of file