Apache ab並發負載壓力測試


由於現在網站都需要能夠承受高並發要求的能力,所以當我們寫完代碼后,如果需要上線,最好都經過壓力測試后,這樣比較好

 

運行: 
在Windows系統下,打開cmd命令行窗口,定位到apache安裝目錄的bin目錄下 
cd C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin

鍵入命令: 
ab -n 800 -c 800  http://192.168.0.10/ 
(-n發出800個請求,-c模擬800並發,相當800人同時訪問,后面是測試url)

ab -t 60 -c 100 http://192.168.0.10/ 
在60秒內發請求,一次100個請求。 
 

 

ab並發負載壓力測試

ab並發負載壓力測試-曾祥展

 

結果參數解釋: 
This is ApacheBench, Version 2.3 <$Revision: 655654 $> 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.10 (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 
Finished 800 requests


Server Software:        Microsoft-HTTPAPI/2.0 
Server Hostname:        192.168.0.10 
Server Port:            80

Document Path:          / 
Document Length:        315 bytes       HTTP響應數據的正文長度

Concurrency Level:      800 
Time taken for tests:   0.914 seconds    所有這些請求處理完成所花費的時間 
Complete requests:      800             完成請求數 
Failed requests:        0                失敗請求數 
Write errors:           0                
Non-2xx responses:      800 
Total transferred:      393600 bytes     網絡總傳輸量 
HTML transferred:       252000 bytes     HTML內容傳輸量 
Requests per second:    875.22 [#/sec] (mean) 吞吐量-每秒請求數 
Time per request:       914.052 [ms] (mean)  服務器收到請求,響應頁面要花費的時間 
Time per request:       1.143 [ms] (mean, across all concurrent requests) 並發的每個請求平均消耗時間 
Transfer rate:          420.52 [Kbytes/sec] received 平均每秒網絡上的流量,可以幫助排除是否存在網絡流量過大導致響應時間延長的問題


網絡上消耗的時間的分解: 
Connection Times (ms) 
              min  mean[+/-sd] median   max 
Connect:        0    1   0.5      1       3 
Processing:   245  534 125.2    570     682 
Waiting:       11  386 189.1    409     669 
Total:        246  535 125.0    571     684

整個場景中所有請求的響應情況。在場景中每個請求都有一個響應時間 
其中 50% 的用戶響應時間小於 571 毫秒 
80 % 的用戶響應時間小於 652 毫秒 
最大的響應時間小於 684 毫秒 
Percentage of the requests served within a certain time (ms) 
  50%    571 
  66%    627 
  75%    646 
  80%    652 
  90%    666 
  95%    677 
  98%    681 
  99%    682 
100%    684 (longest request)

 

這只是測試方法的一種

我經過幾次測試,得出經驗如下:

  1.頁面越復雜需要,並發成功率越低

  lottery.php頁面  這是一個比較復雜的功能頁面

  加載並發:1000  同時在線人數:500

  complete requests : 1000

      Failed request : 965

 

   index.php頁面  這是一個較簡單的功能頁面

  加載並發:1000  同時在線:500

  complete requests : 1000

      Failed request : 15

 


免責聲明!

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



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