Apache Benchとは
Apacheの同梱されている性能テストツール
abとも呼ばれています。
特徴は単一・同一のリクエストを指定したリクエスト分生成します。
webサーバの性能テストで使われます。
シナリオベースでのアプリケーションテストを行うことについては向いていません。
あくまでシンプルな性能テストツールと思ってもらえればと思います。
Apache Benchのインストール
Apache Benchはapacheを入れることで使うことが出来ます。
以下どちらかインストールしてください
- httpdのインストール
yum install httpd
- Apache Benchのみ
これ入れるとhttpd入れなくてもApacheBench使えます。
yum install apr-util
Apache Benchの使い方
実行
- 実行コマンド
ab -n [リクエストの総数] -c [コネクション数(並列実行数)] [URL]
- 実際のコマンド
ab -n 500 -c 100 http://test.com/index.html
「100ユーザから500アクセス来る」というテストになります。
- 他のオプション
オプション | 詳細 |
---|---|
-t | レスポンス待ち時間の指定(/s) |
-A [ユーザ名]:[パスワード] | ベーシック認証の指定 |
-P [ユーザ名]:[パスワード] | 認証の必要なプロキシ |
-X [プロキシのサーバ名]:[ポート番号] | プロキシ経由でリクエストする場合の指定 |
実行結果確認
- 実行結果
$ ab -n 500 -c 100 http://test.com/index.html
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 test.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests
Server Software: Apache/2.4.6
Server Hostname: test.com
Server Port: 80
Document Path: /index.html
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 0.265 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 135500 bytes
HTML transferred: 6000 bytes
Requests per second: 1884.92 [#/sec] (mean)
Time per request: 53.053 [ms] (mean)
Time per request: 0.531 [ms] (mean, across all concurrent requests)
Transfer rate: 498.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 4.9 0 17
Processing: 12 45 13.9 49 71
Waiting: 1 45 13.9 49 71
Total: 15 48 12.2 50 71
Percentage of the requests served within a certain time (ms)
50% 50
66% 54
75% 56
80% 59
90% 62
95% 66
98% 70
99% 71
100% 71 (longest request)
- Concurrency Level : 送信リクエスト数
- Time taken for tests : リクエスト完了までの時間
- Complete requests : 総リクエスト数
- Failed requests : 取りこぼしたリクエスト数
- Write errors : 書き込みエラー数
- Requests per second : 1秒あたりに処理されたリクエスト数
- Time per request : 同時実行したリクエストの平均処理時間(mean)
- Time per request : リクエストの平均処理時間(mean, across all concurrent requests)
- Transfer rate : 1秒あたりに受信された容量
- Connection Times (ms) : 下記の最小値、平均、最大値、平均を記載
- Connect : 接続
- Processing : 処理
- Waiting : 待ち時間
- Total : 集計
- Percentage of the requests served within a certain time (ms) : 処理時間の推移