HTTPサーバのApacheに含まれるベンチマークツールで、HTTPクライアントとして動作する。Apacheをインストールしたディレクトリのbinにあるはずです。私が使っているUbuntu10.04では、すでにパッケージになっており、以下でインストールできました。
sudo apt-get install apache2-utils
ただし、HTTP1.0準拠のようで、持続的接続などは使えず、リクエストの度に、TCPコネクションのコネクト、切断が発生します。
HTTP Getを行う単純な使い方は以下のとおりです。
ad -n [リクエスト数] -c [多重度(スレッド数)] http://[アクセス先]
例えば100個のHTTP GETを、5個のスレッドで送信すると、以下のようになる。
$ ab -n 100 -c 5 http://localhost:8080/index.html
実際に実行すると以下の結果になる。
Server Software: HttpComponents/1.1
Server Hostname: localhost
Server Port: 8080
Document Path: /index.html
Document Length: 100 bytes
Concurrency Level: 5
Time taken for tests: 0.205 seconds <-- 全体でかかった時間
Complete requests: 100 <-- 成功したリクエスト数
Failed requests: 0 <-- 失敗したリクエスト数
Write errors: 0
Total transferred: 23000 bytes
HTML transferred: 10000 bytes
Requests per second: 487.25 [#/sec] (mean) <-- 1秒間の平均リクエスト数(スループット)
Time per request: 10.262 [ms] (mean) <-- 1リクエストにかかった平均時間(レスポンス)
Time per request: 2.052 [ms] (mean, across all concurrent requests)
<-- 多重時に、リクエストを送信してから次の送信までの平均時間(でよい?)
Transfer rate: 109.44 [Kbytes/sec] received
<-- 1秒間の転送サイズ
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 1 10 16.3 5 75
Waiting: 1 9 16.0 4 75
Total: 1 10 16.4 5 77
Percentage of the requests served within a certain time (ms)
50% 5 <-- レスポンス時間の分布(その時間で処理できたリクエストの割合)
66% 7
75% 8
80% 9
90% 29
95% 74
98% 75
99% 77
100% 77 (longest request)
その他のオプションの使い方はhelpを見るとだいたいわかります。
$ ab -h
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-b windowsize Size of TCP send/receive buffer, in bytes
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header for POSTing, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
最終更新:2010年07月31日 06:38