天天看點

使用AB壓力測試工具進行系統壓力測試

ab是apache自帶的一個很好用的壓力測試工具,當安裝完apache的時候,就可以在bin下面找到ab 

下載下傳連結:

Linux/Mac:http://httpd.apache.org/download.cgi#apache24

Windows:http://www.apachehaus.com/cgi-bin/download.plx

下載下傳後解壓,并追加PATH環境變量,如";E:\software\Apache24\bin"

1、我們可以模拟100個并發使用者,對一個頁面發送1000個請求

ab -n1000 -c100 http://vm1.jianfeng.com/a.html

其中-n代表請求數,-c代表并發數

傳回結果:

##首先是apache的版本資訊 

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (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:        Apache-Coyote/1.1    ##apache版本 

Server Hostname:        127.0.0.1   ##請求的機子 

Server Port:            8080 ##請求端口

Document Path:          /

Document Length:        1825 bytes  ##頁面長度

Concurrency Level:      100  ##并發數 

Time taken for tests:   0.273 seconds  ##共使用了多少時間 

Complete requests:      1000   ##請求數 

Failed requests:        0   ##失敗請求 

Total transferred:      275000 bytes  ##總共傳輸位元組數,包含http的頭資訊等 

HTML transferred:       25000 bytes  ##html位元組數,實際的頁面傳遞位元組數 

Requests per second:    3661.60 [#/sec] (mean)  ##每秒多少請求,這個是非常重要的參數數值,伺服器的吞吐量 

Time per request:       27.310 [ms] (mean)  ##使用者平均請求等待時間 

Time per request:       0.273 [ms] (mean, across all concurrent requests)  ##伺服器平均處理時間,也就是伺服器吞吐量的倒數 

Transfer rate:          983.34 [Kbytes/sec] received  ##每秒擷取的資料長度

Connection Times (ms) 

              min  mean[+/-sd] median   max 

Connect:        0    1   2.3      0      16 

Processing:     6   25   3.2     25      32 

Waiting:        5   24   3.2     25      32 

Total:          6   25   4.0     25      48

Percentage of the requests served within a certain time (ms) 

  50%     25  ## 50%的請求在25ms内傳回 

  66%     26  ## 60%的請求在26ms内傳回 

  75%     26 

  80%     26 

  90%     27 

  95%     31 

  98%     38 

  99%     43 

100%     48 (longest request)

2、ab也可以運作在windows中,如果在windows下安裝apache,就可以在bin下找到ab.exe

直接就可以使用,不用依賴其他的dll

下面是我使用ab.exe 測試一個頁面的結果:

C:\Users\Ricky>ab -n1000 -c100 http://live.fuzhuxian.com/

This is ApacheBench, Version 2.3 <$Revision: 1796539 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking live.fuzhuxian.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:        Apache-Coyote/1.1

Server Hostname:        live.fuzhuxian.com

Server Port:            80

Document Path:          /

Document Length:        187 bytes

Concurrency Level:      100

Time taken for tests:   59.833 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      424000 bytes

HTML transferred:       187000 bytes

Requests per second:    16.71 [#/sec] (mean)

Time per request:       5983.334 [ms] (mean)

Time per request:       59.833 [ms] (mean, across all concurrent requests)

Transfer rate:          6.92 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       40   60   6.0     60      80

Processing:    60 5621 1037.3   5912    5996

Waiting:       60 2973 1718.5   2976    5965

Total:        130 5681 1037.1   5972    6056

Percentage of the requests served within a certain time (ms)

  50%   5972

  66%   5987

  75%   6000

  80%   6006

  90%   6020

  95%   6031

  98%   6040

  99%   6046

 100%   6056 (longest request)

3、apache的ab工具也算是一種ddos攻擊工具。

文章主要參考:http://www.cnblogs.com/yjf512/archive/2011/05/24/2055723.html

繼續閱讀