使用方法:
ab: 查看可用的命令(一般用的較多的命令就是 -n -c)

//在測試會話中所執行的請求個數。默認時,僅執行一個請求-n requests Number of requests to perform
//一次產生的請求個數。默認是一次一個。
-c concurrency Number of multiple requests to make
//測試所進行的最大秒數。其內部隱含值是-n 50000。它可以使對服務器的測試限制在一個固定的總時間以內。默認時,沒有時間限制。
-t timelimit Seconds to max. wait for responses
//包含了需要POST的數據的文件.
-p postfile File containing data to POST
//POST數據所使用的Content-type頭信息。
-T content-type Content-type header for POSTing
//設置顯示信息的詳細程度 - 4或更大值會顯示頭信息, 3或更大值可以顯示響應代碼(404, 200等), 2或更大值可以顯示警告和其他信息。 -V 顯示版本號並退出。
-v verbosity How much troubleshooting info to print
//以HTML表的格式輸出結果。默認時,它是白色背景的兩列寬度的一張表。
-w Print out results in HTML tables
// 執行HEAD請求,而不是GET。
-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 cookie-name=value 對請求附加一個Cookie:行。 其典型形式是name=value的一個參數對。此參數可以重復。
-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 proxy-auth-username:password 對一個中轉代理提供BASIC認證信任。用戶名和密碼由一個:隔開,並以base64編碼形式發送。無論服務器是否需要(即, 是否發送了401認證需求代碼),此字符串都會被發送。
-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)
Server Port: 80
Document Path: /
Document Length: 230 bytes//文件長度
Concurrency Level: 10
/*整個測試持續的時間*/
Time taken for tests:0.456 seconds
/*完成的請求數量*/
Complete requests: 10
/*失敗的請求數量*/
Failed requests: 0
Write errors: 0
Non-2xx responses: 10
Keep-Alive requests: 10
/*整個場景中的網絡傳輸量*/
Total transferred: 6020 bytes
/*整個場景中的HTML內容傳輸量*/
HTML transferred: 2300 bytes
/*每秒請求數,后面括號中的 mean 表示這是一個平均值*/
Requests per second: 21.93 [#/sec] (mean)
/*每次請求的響應時間 ,后面括號中的 mean 表示這是一個平均值*/
Time per request: 456.004 [ms] (mean)
/*上面的總時間,下面*/
Time per request: 45.600 [ms] (mean, across all concurrent requests)
/*平均每秒網絡上的流量,可以幫助排除是否存在網絡流量過大導致響應時間延長的問題*/
Transfer rate: 1.55 [Kbytes/sec] received
/*網絡上消耗的時間的分解,各項數據的具體算法還不是很清楚*/
Connection Times (ms)
min mean[+/-sd] median max
Connect: 20 318 926.1 30 2954
Processing: 40 2160 1462.0 3034 3154
Waiting: 40 2160 1462.0 3034 3154
Total: 60 2479 1276.4 3064 3184
/*下面的內容為整個場景中所有請求的響應情況。在場景中每個請求都有一個響應時間,其中 50% 的用戶響應時間小於 3064 毫秒,60 % 的用戶響應時間小於 3094 毫秒,最大的響應時間小於 3184 毫秒*/
Percentage of the requests served within a certain time (ms)
50% 3064
66% 3094
75% 3124
80% 3154
90% 3184
95% 3184
98% 3184
99% 3184
100% 3184 (longest request)