- ab的安裝非常簡單,如果是源碼安裝apache的話,那就更簡單了。apache安裝完畢後ab命令存放在apache安裝目錄的bin目錄下。如下: /usr/local/apache2/bin
- 如果apache 是通過yum的RPM包方式安裝的話,ab命令默認存放在/usr/bin目錄下。如下:
- 可以通過 which ab 來查看是否安裝了ab,以及ab的位置
- ab -V:檢測是否安裝ab以及版本信息
-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.
-m method Method name
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
- 吞吐率(requests per second):描述服務器併發處理能力,單位是reqs/s,只的是在某個併發用戶數下單位時間內能處理的請求數。吞吐率是基於用戶併發數的。
- 併發連接數(he number of concurrent connections):指的是某個時刻服務器所接受的請求書目
- 併發用戶數(Concurrency Level): 要注意區分這個概念和併發連接數之間的區別,一個用戶可能同時會產生多個會話,也即連接數。在HTTP/1.1下,IE7支持兩個併發連接,IE8支持6個併發連接,FireFox3支持4個併發連接,所以相應的,我們的併發用戶數就得除以這個基數
- 用戶平均請求等待時間(Time per request): 處理完成所有請求數所花費的時間/(總請求數/併發用戶數)
- 服務器平均請求等待時間(Time per request:across all concurrent requests): 處理完成所有請求數所花費的時間/總請求數,即:Time taken for/testsComplete requests,可以看到,它是吞吐率的倒數。同時,它也等於用戶平均請求等待時間/併發用戶數,即Time per request/Concurrency Level
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.jd.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: JDWS
Server Hostname: www.jd.com
Server Port: 80
Document Path: /error2.aspx
Document Length: 16503 bytes
Concurrency Level: 100
Time taken for tests: 13.908 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 16870000 bytes
HTML transferred: 16503000 bytes
Requests per second: 71.90 [#/sec] (mean)
Time per request: 1390.829 [ms] (mean)
Time per request: 13.908 [ms] (mean, across all concurrent requests)
min mean[+/-sd] median max
Connect: 7 127 282.3 47 1593
Processing: 27 697 1327.0 190 12730
Waiting: 11 167 374.4 57 3810
Total: 75 824 1425.5 287 12785
Percentage of the requests served within a certain time (ms)
50% 287
66% 586
75% 952
80% 1209
90% 1652
95% 2874
98% 5060
99% 8673
- Server Software:服務器軟件,他這裏用的JDWS(神馬玩意)
- Server Hostname:主機名www.jd.com
- Server Port:端口80
- Document Path:請求文件的路徑
- Document Length:響應文件的正文長度
- 下面關鍵了
- Concurrency Level:併發用戶數,和設置的一樣
- Time taken for tests: 任務處理完所花費的時間
- Complete requests: 總請求量
- Failed requests:失敗的請求量
- Total transferred:示所有請求的響應數據長度總和,包括每個HTTP響應數據的頭信息和正文數據的長度。注意這裏不包括HTTP請求數據的長度,僅僅爲web服務器流向用戶PC的應用層數據總長度
- HTML transferred:表示所有請求的響應數據中正文數據的總和,也就是減去了Total transferred中HTTP響應數據中的頭信息的長度。
- Requests per second : 吞吐率 計算公式:Complete requests/Time taken for tests
- Time per request:用戶平均請求等待時間,計算公式:Time token for tests/(Complete requests/Concurrency Level)。
Time per requet(across all concurrent request):服務器平均請求等待時間,計算公式:Time taken for tests/Complete requests,正好是吞吐率的倒數。也可以這麼統計:Time per request/Concurrency Level。 - Transfer rate:單位時間從服務器獲取數據的長度,這個統計很好的說明服務器的處理能力達到極限時,其出口寬帶的需求量
- Percentage of requests served within a certain time(ms):這部分數據用於描述每個請求處理時間的分佈情況,