Apache ab參數--壓力測試


Apache附帶的ab,它非常容易使用,ab可以直接在Web服務器本地發起測試請求。這至關重要,因為我們希望測試的服務器的處理時間,而不包含數據的網絡傳輸時間以及用戶PC本地的計算時間。

需要清楚的是,ab進行一切測試的本質都是基於HTTP,所以可以說它是對於Web服務器軟件的黑盒性能測試,它獲得的一切數據和計算結果,都可以通過HTTP來解釋。

 

如果沒有安裝,在運行時會提示安裝。

查看ab版本:

wangkongming@Vostro /etc/apache2 $ ab -V
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

 

舉個例子:

wangkongming@Vostro /etc/apache2 $ ab -n 10 -c 10 http://www.baidu.com/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.baidu.com (be patient).....done


Server Software:        Apache-Coyote/1.1
Server Hostname:        www.baidu.com
Server Port:            80

Document Path:          /
Document Length:        521 bytes // 請求的頁面大小

Concurrency Level:      10 //並發量
Time taken for tests:   3.467 seconds //測試總共耗時
Complete requests:      10 //完成的請求
Failed requests:        9 //失敗的請求
   (Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
Total transferred:      880759 bytes //總共傳輸數據量
HTML transferred:       871360 bytes
Requests per second: 2.88 [#/sec] (mean) //每秒鍾的請求量。(僅僅是測試頁面的響應速度)
Time per request: 3466.517 [ms] (mean) //等於 Time taken for tests/(complete requests/concurrency level) 即平均請求等待時間(用戶等待的時間)
Time per request: 346.652 [ms] (mean, across all concurrent requests) //等於 Time taken for tests/Complete requests 即服務器平均請求響應時間 在並發量為1時 用戶等待時間相同
Transfer rate:          248.12 [Kbytes/sec] received //平均每秒多少K,即帶寬速率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       31   34   2.6     35      39
Processing:     2 1962 909.4   2298    3432
Waiting:        2  336 528.4     67    1528
Total:         33 1996 910.9   2337    3466

Percentage of the requests served within a certain time (ms)
  50%   2337
  66%   2467
  75%   2497
  80%   2588
  90%   3466
  95%   3466
  98%   3466
  99%   3466
 100%   3466 (longest request)

 

參數說明:

-n 10 表示總請求數為10,共發出了10次請求
-c 10 表示並發用戶數為10,同時有10個用戶訪問
http://www.baidu.com/ 表示這些請求的目標URL (注意,目標地址后面一定要加結束的反斜杠/)

 

關注的參數:

Requests per second:每秒的請求量,所謂的吞吐率。【這個值越小越好】

Time per request: 3466.517 [ms] (mean)  即平均請求等待時間,也是吞吐率(用戶等待的時間) mean表示平均值
Time per request: 346.652 [ms] (mean, across all concurrent requests) //服務器平均請求響應時間 在並發量為1時 用戶等待時間相同 【這個值越大越好】

簡單總結下:

Requests per second 的值越小越好,Time per request 的值越大越好

 

 

參考資料:

http://blog.itpub.net/29773961/viewspace-1470071/

https://blog.linuxeye.com/124.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM