Apache ab 測試結果的分析

2021-08-31 16:58:54 字數 4919 閱讀 3674

以前安裝好apache總是不知道該如何測試apache的效能,現在總算找到乙個測試工具了。就是apache自帶的測試工具ab(apache benchmark).在apache的bin目錄下。

格式: ./ab [options] [http://]hostname[:port]/path

引數:-n requests     number of requests to perform

//在測試會話中所執行的請求個數。預設時,僅執行乙個請求

-c concurrency number of multiple requests to make

//一次產生的請求個數。預設是一次乙個。 

-t timelimit    seconds to max. wait for responses

//測試所進行的最大秒數。其內部隱含值是-n 50000。它可以使對伺服器的測試限制在乙個固定的總時間以內。預設時,沒有時間限制。

-p postfile     file containing data to post

//包含了需要post的資料的檔案. 

-t content-type content-type header for posting

//post資料所使用的content-type頭資訊。

-v verbosity    how much troubleshooting info to print

//設定顯示資訊的詳細程度 - 4或更大值會顯示頭資訊, 3或更大值可以顯示響應**(404, 200等), 2或更大值可以顯示警告和其他資訊。 -v 顯示版本號並退出。

-w              print out results in html tables

//以html表的格式輸出結果。預設時,它是白色背景的兩列寬度的一張表。

-i              use head instead of get

// 執行head請求,而不是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    add cookie, eg. 『apache=1234. (repeatable)

//-c cookie-name=value 對請求附加乙個cookie:行。 其典型形式是name=value的乙個引數對。此引數可以重複。

-h attribute    add arbitrary header line, eg. 『accept-encoding: gzip』

inserted after all normal header lines. (repeatable)

-a attribute    add basic www authentication, the attributes

are a colon separated username and password.

-p attribute    add basic proxy authentication, the attributes

are a colon separated username and password.

//-p proxy-auth-username:password 對乙個中轉**提供basic認證信任。使用者名稱和密碼由乙個:隔開,並以base64編碼形式傳送。無論伺服器是否需要(即, 是否傳送了401認證需求**),此字串都會被傳送。

//-attributes 設定 屬性的字串. 缺陷程式中有各種靜態宣告的固定長度的緩衝區。另外,對命令列引數、伺服器的響應頭和其他外部輸入的解析也很簡單,這可能會有不良後果。它沒有完整地實現 http/1.x; 僅接受某些』預想』的響應格式。 strstr(3)的頻繁使用可能會帶來效能問題,即, 你可能是在測試ab而不是伺服器的效能。

引數很多,一般我們用 -c 和 -n 引數就可以了. 例如:

./ab -c 1000 -n 1000 

這個表示同時處理1000個請求並執行1000次index.php檔案.

#/usr/local/xiaobai/apache2054/bin/ab -c 1000 -n 1000 

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

finished 1000 requests

server software:        apache/2.0.54

//平台apache 版本2.0.54

server hostname:        127.0.0.1

//伺服器主機名

server port:            80

//伺服器端口

document path:          /index.html.zh-cn.gb2312

//測試的頁面文件

document length:        1018 bytes

//文件大小

concurrency level:      1000

//併發數

time taken for tests:   8.188731 seconds

//整個測試持續的時間

complete requests:      1000

//完成的請求數量

failed requests:        0

//失敗的請求數量

write errors:           0

total transferred:      1361581 bytes

//整個場景中的網路傳輸量

html transferred:       1055666 bytes

//整個場景中的html內容傳輸量

requests per second:    122.12 [#/sec] (mean)

//大家最關心的指標之一,相當於 lr 中的每秒事務數,後面括號中的 mean 表示這是乙個平均值

time per request:       8188.731 [ms] (mean)

//大家最關心的指標之二,相當於 lr 中的平均事務響應時間,後面括號中的 mean 表示這是乙個平均值

time per request:       8.189 [ms] (mean, across all concurrent requests)

//每個請求實際執行時間的平均值

transfer rate:          162.30 [kbytes/sec] received

//平均每秒網路上的流量,可以幫助排除是否存在網路流量過大導致響應時間延長的問題

connection times (ms)

min mean[+/-sd] median   max

connect:        4 646 1078.7     89    3291

processing:   165 992 493.1    938    4712

waiting:      118 934 480.6    882    4554

total:        813 1638 1338.9   1093    7785

//網路上消耗的時間的分解,各項資料的具體演算法還不是很清楚

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

50%   1093

66%   1247

75%   1373

80%   1493

90%   4061

95%   4398

98%   5608

99%   7368

100%   7785 (longest request)

//整個場景中所有請求的響應情況。在場景中每個請求都有乙個響應時間,其中50%的使用者響應時間小於1093 毫秒,60% 的使用者響應時間小於1247 毫秒,最大的響應時間小於7785 毫秒

由於對於併發請求,cpu實際上並不是同時處理的,而是按照每個請求獲得的時間片逐個輪轉處理的,所以基本上第乙個time per request時間約等於第二個time per request時間乘以併發請求數

Apache ab 壓力測試結果分析

測試說明 模擬100個使用者,對伺服器發起總共1000次請求。測試命令 ab n 1000 c 100 測試報告如下圖 apache的版本資訊 測試完成度 benchmarking be patient completed 100 requests completed 200 requests co...

Apache ab效能測試結果分析

一直以來我都是用loadrunner去做效能測試。loadrunner實際上是乙個很重的效能測試工具。他的功能很全面,是一把很好的牛刀。如果我們只是需要對乙個頁面做簡單的效能測試,使用loadruner這把牛刀就不是乙個很好的選擇了。測試命令 ab n 100 c 10 本文主要針對ab的測試報告進...

ab測試,Apache ab 測試結果的分析

以前安裝好 apache總是不知道該如何測試 apache的效能,現在總算找到乙個測試工具了。就是 apache自帶的測試工具ab apache benchmark 在 apache的bin目錄下。time per request 8188.731 ms mean 大家最關心的指標之二,相當於 lr...