ApacheBench(ab)壓力測試工具

服務器負載太大而影響程序效率也是很常見的,Apache服務器自帶有一個叫AB(ApacheBench)的工具,能夠對服務器進行負載測試html

 

基本用法:apache

ab  -n 所有請求數 -c 併發數測試url服務器

注:能夠將ab.exe 加入系統環境變量;或直接切換置 ab 目錄執行。如: C:\Windows\System32> cd C:\xampp\apache\bin cookie

例:C:\xampp\apache\bin>ab -n 1000 -c 50 http://www.abc.com/index.html併發

 

更爲詳細操做ide

------------------------------------------------------------------------------------------------ 工具

C:\xampp\apache\bin>ab-n 100 -c 10 http://www.abc.com/index.htmlpost

This is ApacheBench, Version 2.0.40-dev<$Revision: 1.146 $> apache-2.0測試

Copyright 1996 Adam Twiss, Zeus TechnologyLtd, http://www.zeustech.NET/this

Copyright 2006 The Apache SoftwareFoundation, http://www.apache.org/

 

Benchmarking www.abc.com (bepatient).....done

 

Server Software:        Apache

Server Hostname:       www.abc.com

Server Port:            80

 

Document Path:          /index.html

Document Length:        17784 bytes     #請求文檔大小

 

Concurrency Level:      10              #併發數

Time taken for tests:   11.898681 seconds    #所有請求完成耗時

Complete requests:      100            #所有請求數     

Failed requests:        0

Write errors:           0

Total transferred:      1805900 bytes      #總傳輸大小

HTML transferred:       1778400 bytes

Requests per second:    8.40 [#/sec] (mean)    #每秒請求數(平均)

Time per request:       1189.868 [ms] (mean)  #每次併發請求時間(全部併發)

Time per request:       118.987 [ms] (mean, across all concurrentrequests

Transfer rate:          148.17 [Kbytes/sec] received    #傳輸速率

 

Connection Times (ms)           #鏈接時間

                      min mean[+/-sd]  median(中位值)  max

Connect: #鏈接)     59   73  11.9     72     132

Processing: #處理)    86   998538.7     938   2288

Waiting: #等待)     63   135 106.8     94    663

Total:                 155  1072540.6    1004   2362

 

在必定比例的請求服務時間

 

 50%   1004

 66%   1260

 75%   1452

 80%   1492

 90%   1923

 95%   2078

 98%   2352

 99%   2362

 100%  2362 (longest request)

 ----------------------------------------------------------------------------------------------------------------------------

#整個場景中全部請求的響應狀況,在場景中每一個請求都有一個響應時間,其中

50%的用戶響應時間小於1104毫秒,

80%的用戶響應時間小於1492毫秒,

最大的響應時間小於2362毫秒。

 

備:因爲對發請求,cpu實際上並非同時處理的,而是按照每一個請求得到的時間片逐個輪轉處理的,因此,基本上第一個Timeper request時間約等於第二個Timeper request時間乘以併發請求數。

 

 

 

其它參數:

-n  requests     所有請求數

-c  concurrency  併發數

-t  timelimit     最傳等待迴應時間

-p  postfile      POST數據文件

-T  content-type  POST Content-type

-v  verbosity     Howmuch troubleshooting info to print

-w              Print outresults in HTML tables

-i               Use HEAD instead of GET

-x  attributes    String to insert as table attributes

-y  attributes    String to insert as tr attributes

-z  attributes    String to insert as td or th attributes

-C  attribute    加入cookie, eg.'Apache=1234. (repeatable)

-H  attribute    加入http頭, eg.'Accept-Encoding: gzip'

                Inserted after all normalheader lines. (repeatable)

-A  attribute    http驗證,分隔傳遞用戶名及密碼

-P  attribute    Add Basic Proxy Authentication, theattributes

                are a colon separated usernameand password.

-X  proxy:port   代理服務器

-V              查看ab版本

-k              Use HTTPKeepAlive feature

-d              Do not showpercentiles served table.

-S              Do not showconfidence estimators and warnings.

-g  filename     Output collected data to gnuplot formatfile.

-e  filename     Output CSV file with percentages served

-h              Display usageinformation (this message)

相關文章
相關標籤/搜索