2011-09-28 Apache Benchの利用
Apache Benchの利用
apache benchはApacheに付属している負荷試験用のソフトウェアです。
簡易なテストであれば十分に利用できます。
注意点としては、単一のリクエストに対してのテストしか実行してくれません。
というのは、アクセス先のプログラムが画像データを利用していたとしても、画像のリクエスト処理は行われません。
総合的な負荷試験を行いたい場合はJMeterを利用しましょう。
abコマンドの利用方法
※自分が管理しているサーバ以外で絶対に実行しないでください。ユーザエージェントにApache Benchとしてアクセスログに記録されるのでバレます。
ab -n リクエスト数 -c 同時実行のリクエスト数 サーバーアドレス
というように利用します。
ab -n 10000-c 100 http://localhost
この例だと同時100接続で10000リクエストを処理させることになります。
他にもabには様々なオプションが存在します。
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
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-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
-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)
主なオプションは以下にまとめました。
| -n | 発行するリクエストの回数 |
| -c | 同時に発行するリクエストの数 |
| -t | レスポンスの待ち時間の秒数 |
| -p | サーバへ送信するファイルを指定 |
| -T | Content-typeヘッダーを指定 |
| -w | 結果をHTMLで出力 |
| -C | Cookieを指定 |
| -A | Basic認証を利用する |
| -X | プロキシ経由でリクエスト |
| -V | abのバージョン表示 |
| -k | KeepAliveの有効化 |
- 4 http://www.google.co.jp/url?sa=t&source=web&cd=1&ved=0CBsQFjAA&url=http://d.hatena.ne.jp/fat47/20110927/1317094663&rct=j&q=mysql 5.5.16 cmake&ei=VBqDTojrC4uNmQWixvkt&usg=AFQjCNHvGzCqP8iO5ECvYRGB8OMJVBAgpg&sig2=xQp3mPVUuFxTe1URw9T76g
- 2 http://d.hatena.ne.jp/keyword/ソースコード
- 2 http://www.google.co.jp/search?q=yum+zabbix+エラー&hl=ja&lr=lang_ja&client=firefox-a&hs=o44&rls=org.mozilla:ja:official&tbs=lr:lang_1ja,qdr:m&prmd=imvns&source=lnt&sa=X&ei=hbWDTtuvH-f4mAWS5tAe&ved=0CBEQpwUoBA&biw=1167&bih=706
- 1 http://bit.ly/na42oM
- 1 http://bit.ly/onVTlB
- 1 http://bit.ly/pPF7GW
- 1 http://www.google.co.jp/search?hl=&q=CentOS5.6+rpm+mysql+インストール&sourceid=navclient-ff&rlz=1B3MOZA_jaJP421JP421&ie=UTF-8
- 1 http://www.google.co.jp/search?hl=ja&client=firefox-a&hs=UPr&rls=org.mozilla:ja:official&q=php5.3.8+centos&oq=php5.3.8+centos&aq=f&aqi=&aql=1&gs_sm=e&gs_upl=31066l35214l0l35269l12l12l0l6l6l1l197l771l3.3l6l0
- 1 http://www.google.co.jp/search?hl=ja&q=centos+date+edt+jst&lr=lang_ja
- 1 http://www.google.co.jp/search?num=50&lr=lang_ja&q=CentOS6 テキスト インストール
