先日Apacheの子プロセス数のチューニングを行ったため、性能試験を行いたくなりました。調べたところabコマンド(Apache Bench)が一番簡単そう。私の環境はMac OS Catalinaですが、なにもインストールすることなく使える状態でした。
使用方法
$ ab -n 300 -c 30 https://www.abc.com/
-nはリクエスト数 -cで同時接続数を指定します。
実際に試験してみた
このサイトを試験したところこんな感じ
$ ab -n 300 -c 30 https://karakunphoto.com/ This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking karakunphoto.com (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Finished 300 requests Server Software: nginx/1.17.9 Server Hostname: karakunphoto.com Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256 Server Temp Key: ECDH X25519 253 bits TLS Server Name: karakunphoto.com Document Path: / Document Length: 37446 bytes Concurrency Level: 30 Time taken for tests: 41.501 seconds Complete requests: 300 Failed requests: 0 Total transferred: 11323500 bytes HTML transferred: 11233800 bytes Requests per second: 7.23 [#/sec] (mean) Time per request: 4150.096 [ms] (mean) Time per request: 138.337 [ms] (mean, across all concurrent requests) Transfer rate: 266.45 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 31 52 37.2 41 186 Processing: 300 3887 701.6 4026 4455 Waiting: 282 3806 698.8 3944 4373 Total: 360 3939 679.0 4064 4495 Percentage of the requests served within a certain time (ms) 50% 4064 66% 4134 75% 4185 80% 4251 90% 4365 95% 4395 98% 4423 99% 4474 100% 4495 (longest request)
多分遅いです。
なお、Apache2の子プロセス設定がデフォルトの場合は以下
$ ab -n 300 -c 30 https://karakunphoto.com/ This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking karakunphoto.com (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Finished 300 requests Server Software: nginx/1.17.9 Server Hostname: karakunphoto.com Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256 Server Temp Key: ECDH X25519 253 bits TLS Server Name: karakunphoto.com Document Path: / Document Length: 37446 bytes Concurrency Level: 30 Time taken for tests: 59.233 seconds Complete requests: 300 Failed requests: 0 Total transferred: 11323500 bytes HTML transferred: 11233800 bytes Requests per second: 5.06 [#/sec] (mean) Time per request: 5923.322 [ms] (mean) Time per request: 197.444 [ms] (mean, across all concurrent requests) Transfer rate: 186.69 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 29 69 45.6 49 187 Processing: 1087 5618 2437.7 4732 12437 Waiting: 948 5000 2385.6 3977 11695 Total: 1135 5687 2446.7 4773 12475 Percentage of the requests served within a certain time (ms) 50% 4773 66% 5190 75% 5741 80% 6327 90% 10319 95% 10592 98% 11891 99% 11926
子プロセスが生成されて大量にページングが発生していたので、絞っている状態の方が速い結果となりました。
参考Apache設定
mpm_prefork.conf (デフォルト設定) StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxRequestWorkers 150 MaxConnectionsPerChild 0
mpm_prefork.conf (絞った後の設定) StartServers 5 MinSpareServers 5 MaxSpareServers 5 MaxRequestWorkers 5 MaxConnectionsPerChild 0
“WEBサイトレスポンスタイムを簡易計測する” に1件のコメント