Summery
ab コマンドは、(Apache Bench)の頭文字で、サーバーの負荷テストを行うベンチテストコマンドです。
ずっとABテストコマンドだと思っていたんですが、違っていました。
本番サーバーでこのコマンドを叩いてしまうと、サーバーがダウンする事があるので、実は要注意コマンドなのです。
サーバーのハードウェアを知るために、このコマンドを使って、1つのサーバーの限界値を調査するような事ができれば、apacheの設定値などでのアクセス上限値を決めることに役立つ事でしょう。
Construction
$ ab [option] [count] [url]
Option
-n : リクエスト回数
-c : 同時アクセス数
-k : keepAliveを有効にする
url : 問い合わせを行うURL
Sample
# 同時10アクセスで20リクエストの場合
$ ab -n 20 -c 10 http://hoge.com/test.php
# [結果]
This is ApacheBench, Version 2.3 < $Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software: Apache/2.2.29
Server Hostname: localhost
Server Port: 8888
Document Path: /
Document Length: 775 bytes
Concurrency Level: 10
Time taken for tests: 0.081 seconds
Complete requests: 10
Failed requests: 0
Total transferred: 10640 bytes
HTML transferred: 7750 bytes
Requests per second: 122.90 [#/sec] (mean)
Time per request: 81.365 [ms] (mean)
Time per request: 8.137 [ms] (mean, across all concurrent requests)
Transfer rate: 127.70 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.2 1 1
Processing: 80 80 0.1 80 80
Waiting: 80 80 0.1 80 80
Total: 80 81 0.3 81 81
Percentage of the requests served within a certain time (ms)
50% 81
66% 81
75% 81
80% 81
90% 81
95% 81
98% 81
99% 81
100% 81 (longest request)
実行結果として、apacheのバージョンやアクセス情報などが表示され、リクエスト回数分の各々かかったミリ秒(ms)が表示される。
Discription
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-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 to use for POST/PUT data, 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.
-q Do not show progress when doing more than 150 requests
-l Accept variable document length (use this for dynamic pages)
-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)
MacBookAiryugetakoji:sitemate yugeta$ ab -n 10 -c 2 http://ideacompo.com
ab: invalid URL
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 at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-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 to use for POST/PUT data, 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.
-q Do not show progress when doing more than 150 requests
-l Accept variable document length (use this for dynamic pages)
-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)
0 件のコメント:
コメントを投稿