ab.exe目錄
apache\bin
ab相關指令:
Options are:
-n requests Number of requests to perform(請求的總數,預設是1次。)
-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
-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 for POSTing, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain' (設定請求頭中的Content-type(針對POST/PUT),比如:application/x-www-form-urlencoded。預設是text/plain。)
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables (将測試結果列印到HTML表格中。)
-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.( 如果後面接的是檔案,表示POST請求,檔案中包含請求資料,根據資料格式,設定-T參數。)
-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)
執行個體:
ab -c 300 -n 300 "http://www.abc.com:80/test/aaaa?a=1&b=2&c=3"
測試結果樣例:
Concurrency Level 并發數多少,等于-c後面的數值
Time taken for tests 測試總耗時
Complete requests 成功收到傳回的數目
Failed requests 請求失敗數目,可能因為網絡連接配接,異常,請求資料長度等等
Non-2xx responses 表示傳回的HTTP status code不是2xx的數目(比如404,401,500...),如果都是2xx,這個名額不顯示在結果裡面
Requests per second 每秒請求數,等于總請求數/測試總耗時
Time per request 每一個請求平均花費時間。第一個Time per request等于concurrency * timetaken * 1000 / done,第二個Time per request(mean, across all concurrency requests)等于timetaken * 1000 / done,第一個可以了解為使用者平均請求等待時間,第二可以了解為伺服器平均請求等待時間