標籤:blog http 使用 strong os for
對於網站效能測試來說,一般我們會使用loadrunner來實現,而它過於龐大,使我們感到有些不爽,而今天介紹的ApacheBench工具,它小而精,使用簡單,效果直觀,可以說,是比lr更好用的效能測試工具.
對於ApacheBench我們可以從這裡下載 工具下載
下面介紹幾個概念
1:吞吐率(Requests per second)
伺服器並發處理能力的量化描述,單位是reqs/s,指的是某個並發使用者數下單位時間內處理的請求數。某個並發使用者數下單位時間內能處理的最大請求數,稱之為最大吞吐率。
記住:吞吐率是基於並發使用者數的。這句話代表了兩個含義,1:吞吐率和並發使用者數相關;2:不同的並發使用者數下,吞吐率一般是不同的。
計算公式:總請求數 / 處理完成這些請求數所花費的時間,即
Request per second = Complete requests / Time taken for tests
2:並發串連數(The number of concurrent connections)
並發串連數指的是某個時刻伺服器所接受的請求數目,簡單的講,就是一個會話。
3:並發使用者數(The number of concurrent users,Concurrency Level)
要注意區分這個概念和並發串連數之間的區別,一個使用者可能同時會產生多個會話,也即串連數。在HTTP/1.1下,IE7支援兩個並發串連,IE8支援6個並發串連,FireFox3支援4個並發串連,所以相應的,我們的並發使用者數就得除以這個基數。
下面主要說一下它的幾個主要的參數
運行參數
請求為100,並發為10,命令如下:ApacheBench -n100 -c10 http://uri
運行結果
Benchmarking www.cnblogs.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
Finished 1000 requests
Server Software:
Server Hostname: www.cnblogs.com
Server Port: 80
Document Path: /
Document Length: 45373 bytes
Concurrency Level: 10
Time taken for tests: 45.299591 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 45679011 bytes
HTML transferred: 45373000 bytes
Requests per second: 22.08 [#/sec] (mean)
Time per request: 452.996 [ms] (mean)
Time per request: 45.300 [ms] (mean, across all concurrent requests)
Transfer rate: 984.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 26 44 189.5 31 3035
Processing: 89 405 583.3 284 5190
Waiting: 30 143 344.6 97 5031
Total: 116 450 611.7 315 5224
Percentage of the requests served within a certain time (ms)
50% 315
66% 322
75% 331
80% 343
90% 408
95% 549
98% 3333
99% 3375
100% 5224 (longest request)