Open5
Apache Bench とは
性能テストツール
負荷をかけてサーバーの性能をテストする
Apache HTTP Serverに同封されている。
コマンド名にちなんでabと呼ばれる
基本的な使い方
$ ab -n x -c y URL
- n オプション:生成するリクエスト数
- cオプション:並列実行数
例えば、
10ユーザーが、10回ずつリクエストする場合には以下のコマンドを打つ
$ ab -n 100 -c 10 y example.co.jp
適当にテストしてみた。
結果を読んで見る。
// 2ユーザーが5リクエストずつhttps://hoge.co.jp/にリクエスト
$ ab -n 10 -c 2 https://hoge.co.jp/
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
// ベンチマークテスト終了
Benchmarking hoge.co.jp (be patient).....done
Server Software: Apache
Server Hostname: hoge.co.jp
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
Server Temp Key: ECDH P-256 256 bits
TLS Server Name: hoge.co.jp
Document Path: /
Document Length: 238 bytes
Concurrency Level: 2
Time taken for tests: 0.695 seconds
Complete requests: 10 // 成功したリクエスト数
Failed requests: 0 // 失敗したリクエスト数
Non-2xx responses: 10
Total transferred: 5590 bytes
HTML transferred: 2380 bytes
Requests per second: 14.39 [#/sec] (mean) // 1ミリ秒間に処理した平均リクエスト数
Time per request: 139.004 [ms] (mean) // 1リクエストに要した平均ミリ秒
Time per request: 69.502 [ms] (mean, across all concurrent requests)
Transfer rate: 7.85 [Kbytes/sec] received
// リクエストに要したミリ秒数の内訳
Connection Times (ms)
min mean[+/-sd] median max
Connect: 44 57 16.4 53 102
Processing: 50 56 3.5 57 61
Waiting: 50 56 3.5 56 61
Total: 96 113 17.0 110 159
//
Percentage of the requests served within a certain time (ms)
50% 110
66% 111
75% 113
80% 114
90% 159
95% 159
98% 159
99% 159
100% 159 (longest request)
wオプションをつけることで、htmlで出力できる。
wオプションをつけるときには、必ず出力先のファイルを指定する
ab -n 10 -c 2 -w https://hoge.co.jp/ > result.html