Apacheのabでベンチマークテスト

スポンサーリンク
スポンサーリンク
ライフスタイル関連のコンテンツ
お金 | 仕事 | 勉強 | プライベート | 健康 |
プログラミング関連のコンテンツ
C言語/C++入門 | Ruby入門 | Python入門 | プログラミング全般

Apacheに付属しているab(Apache Bench)というツールで、リクエストに対する接続の負荷テストを行って見た。
ローカルマシン(Windows)から、このブログに対して実験。
ちなみに、私のローカルマシン(Windows)には、xamppをインストールしてあり、ab(ab.exe)は、「C:\xampp\apache\bin」に入っていることを確認できました。
コマンドラインから実行させるため、まずはコマンドプロンプトを立ち上げ、

スポンサーリンク

$ cd C:\xampp\apache\bin

で、abが入っているパスへ移動。
次に、以下のコマンドを打つと、abのヘルプを見ることができる。

C:\xampp\apache\bin>ab
ab: wrong number of arguments
Usage: ab [options] [http://]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
    -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)

リクエスト負荷テストの場合、-nと-cのオプションくらいを使えば良いらしい。
-nがリクエストの回数、-cが同時発行のリクエスト数。
以下のように、リクエスト回数を100回、同時発行を10個として、テストしてみました。

C:\xampp\apache\bin>ab -n 100 -c 10 http://www.example.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
 
Benchmarking www.example.com (be patient).....done
 
Server Software:        Apache/1.3.34
Server Hostname:        www.example.com
Server Port:            80
 
Document Path:          /wlh/
Document Length:        67417 bytes
 
Concurrency Level:      10
Time taken for tests:   9.516 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      6769400 bytes
HTML transferred:       6741700 bytes
Requests per second:    10.51 [#/sec] (mean)
Time per request:       951.563 [ms] (mean)
Time per request:       95.156 [ms] (mean, across all concurrent requests)
Transfer rate:          694.72 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       31   87  19.0     94     125
Processing:   469  814  77.6    844     953
Waiting:       47  234  74.0    203     469
Total:        500  901  86.0    922    1031
 
Percentage of the requests served within a certain time (ms)
  50%    922
  66%    938
  75%    953
  80%    953
  90%    969
  95%    969
  98%    984
  99%   1031
 100%   1031 (longest request)

Document Length: 67417 bytes
 リクエスト先ドキュメントのバイト数を確認できる。
Total transferred: 6769400 bytes
 その100倍(リクエスト回数)となるバイト数を確認できる。
Requests per second: 10.51 [#/sec] (mean)
 1秒当たりの処理リクエスト数。
Time per request: 95.156 [ms] (mean, across all concurrent requests)
 1リクエスト当たりの秒数(ミリセカンド)。
Transfer rate: 694.72 [Kbytes/sec] received
 1秒当たりの転送バイト数。

こんなものなのだろうか・・・?
なんかちょっと遅い気がしますけど、トップページのドキュメントが67キロバイト/ほどあるのは、ちょっと重すぎかもしれない。
アクセス数が増えたら、ダイエットが必要かもしれないですね。

参考:
お仕事日記:apache ベンチマークツール ab を使ってみる – livedoor Blog(ブログ)
Apache Bench で性能測定だ – IT革命〜
@IT:Apacheパフォーマンス・チューニングのポイント(2/2)

スポンサーリンク
 
スポンサーリンク