ab コマンドの使い方
ab は Apache Bench の略
Webサーバーの性能確認をするためのツール
主なオプション
-c クライアント数
-n トータルのリクエスト数
使用例
ab -c 10 -n 1000 http://example.com/
上記の場合は、10個のクライアントでトータル1000回(1クライアントあたり100回)のリクエストを http://example.com/ というURLに送る
http://example.com/ の末尾の / は省略するとエラーになる
結果の見方
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking example.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.20.1
Server Hostname: example.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
Document Path: /
Document Length: 2539 bytes
Concurrency Level: 10
Time taken for tests: 20.186 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 2814000 bytes
HTML transferred: 2539000 bytes
Requests per second: 49.54 [#/sec] (mean)
Time per request: 201.856 [ms] (mean)
Time per request: 20.186 [ms] (mean, across all concurrent requests)
Transfer rate: 136.14 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 3 9 9.6 4 67
Processing: 39 192 53.6 189 367
Waiting: 38 192 53.6 189 367
Total: 43 201 54.5 199 391
Percentage of the requests served within a certain time (ms)
50% 199
66% 222
75% 236
80% 245
90% 273
95% 292
98% 322
99% 343
100% 391 (longest request)
Complete requests と Failed requests
Complete requests の部分が -n で指定した数と一致していればOK
Failed requests の部分が 0 になっていればOK
指定した同時接続数(クライアント数)で指定のリクエスト数を処理できている
requests per second
1秒間に処理できるリクエスト数
Requests per second: 49.54 となっていれば、1秒に49.54個のリクエストを処理できるスペックがある
Time per request
1リクエストあたりにかかる処理時間
Time per request: 20.186 [ms] (mean, across all concurrent requests)
上記のように表示されていれば、1リクエストあたり20.186ms(ミリ秒)かかっている
Time per request: 201.856 [ms] (mean)
の部分は、10クライアントで同時接続したので、10クライアント分の処理をするのに10倍のタイムがかかっているという意味
JavaScriptの処理時間は含まない
abコマンドは簡易ツールなのでサーバーからレスポンスが返ってくるまでのタイムを計っているだけ
JavaScriptの処理時間やiframeの読み込みにかかる時間は含まない
ユーザーが感じる現実的なページ表示までの時間とは異なるので注意