Apache ab 測試載入器使用(一)

來源:互聯網
上載者:User

標籤:des   blog   http   io   ar   os   使用   sp   for   

簡述:

試用apache ab測試載入器

 

下載點

http://httpd.apache.org/download.cgi

參考:

http://jingyan.baidu.com/article/e3c78d647a57833c4c85f502.html

 

ab的參數說明

-n  需要執行的請求次數

-c  並發的數量

-t   等待返回的最長時間

-b  TCP收發緩衝區的大小,單位(byte)

-p 使用post (同時需要定義-T參數)

-u 使用put (同時需要定義-T參數)

-T content-type, 例如application/x-www-form-urlencoded, 預設為text/plain

-w 把結果列印在html的表格裡

-x  表格的屬性

-y  tr行屬性

-z  td列屬性

-C 設定cookie 例如Apach=1234

-H header行, 例如Accept-Encoding:gzip

-k 是否標示位HTTP Keep Alive 

 

 

 

步驟:

1. 配置環境變數

 

配置完成

 

2. 下面就拿apache的一個靜態頁面做測試

測試command, 

 

[plain] view plaincopy 
  1. ab -n 1000 -c 100 -w http://localhost/a.htm >>C:\Users\Administrator\Desktop\ab_test\result.html  


 

 

 

測試結果:

 

[plain] view plaincopy 
  1. This is ApacheBench, Version 2.3 <$Revision: 655654 $>  
  2. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/  
  3. Licensed to The Apache Software Foundation, http://www.apache.org/  
  4.   
  5. Benchmarking localhost (be patient)  
  6.   
  7.   
  8. Server Software:        Apache/2.2.25  
  9. Server Hostname:        localhost  
  10. Server Port:            80  
  11.   
  12. Document Path:          /a.htm  
  13. Document Length:        319 bytes  
  14.   
  15. Concurrency Level:      100  
  16. Time taken for tests:   0.325 seconds  
  17. Complete requests:      1000  
  18. Failed requests:        0  
  19. Write errors:           0  
  20. Total transferred:      581000 bytes  
  21. HTML transferred:       319000 bytes  
  22. Requests per second:    3076.74 [#/sec] (mean)  
  23. Time per request:       32.502 [ms] (mean)  
  24. Time per request:       0.325 [ms] (mean, across all concurrent requests)  
  25. Transfer rate:          1745.69 [Kbytes/sec] received  
  26.   
  27. Connection Times (ms)  
  28.               min  mean[+/-sd] median   max  
  29. Connect:        0    0   0.3      0       1  
  30. Processing:    11   31   5.2     31      45  
  31. Waiting:       11   31   5.2     30      45  
  32. Total:         12   31   5.2     31      46  
  33.   
  34. Percentage of the requests served within a certain time (ms)  
  35.   50%     31  
  36.   66%     32  
  37.   75%     33  
  38.   80%     35  
  39.   90%     38  
  40.   95%     40  
  41.   98%     42  
  42.   99%     43  
  43.  100%     46 (longest request)  

 

 

附:

測試頁面如下

 

下面是帶參數的請求,

 

[plain] view plaincopy 
  1. ab -n 1000 -c 100 -p C:\Users\Administrator\Desktop\ab_test\params.txt -T application/x-www-form-urlencoded http://localhost/result.html >>C:\Users\Administrator\Desktop\ab_test\result.html  



 

如果是帶有cookie的請求

param.txt

 

[plain] view plaincopy 
  1. trainId=aaaa&topicCategory=b&topicRelation=a&userRoleCode=a1&searchText=  



 

command:

 

[plain] view plaincopy 
  1. ab -n 10 -c 5 -p C:\Users\Administrator\Desktop\ab_test\params.txt -C "JSESSIONID=v1234hjwcx8k1e8trwh1ipjso; paramA=5322155; paramB=V12EE0186; edu.yale.its.tp.cas.client.filter.receipt=23/20/49/23/23/21/23/124/69/48/48/20/21/48/49/26/24/124/116/101/108/101/99/111/109/124/49/22/48/22/49/21/22/24/23/21/49/49/27/" -T application/x-www-form-urlencoded -w http://127.0.0.1:8080/cpa/topic/student/getTopicInfo >>C:\Users\Administrator\Desktop\ab_test\result.html  



 

最後查看html的測試結果

 

測試結果:

Apache ab 測試載入器使用(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.