ab測試,200個請求,20個併發.這樣的測試強度,cpu佔了70-80%,w3p占用了70多m記憶體,本想多測幾次,看看它的記憶體會不會漲上去,沒 有測試機器沒辦法,開發機要幹活.我估計cpu就有問題了,效能有好些個地方還需要優化.
順便把測試的工具用法作個記號
基本用法
:ab -n
全部請求數
-c併發數
測試url
例:ab -n 1000 -c 50
/server software:
microsoft-iis/7.0
server hostname:
www.newdev.gztest.com
server port:
80document path:
document length:
82522 bytes #
請求文件大小
concurrency level:
50
#併發數
time taken for tests: 92.76140 seconds #
全部請 求完成耗時
complete requests:
10000
#全部請求數
failed requests:
1974
#失敗的請求
(connect: 0, length: 1974, exceptions: 0)
write errors:
0total transferred:
827019400 bytes
#總傳輸大小
html transferred:
825219400 bytes
//整個場 景中的html內容傳輸量
requests per second:
108.61 [#/sec] (mean)
#每秒請 求數(平均
)//大家最關心的指標之一,相當於
lr中的
每秒事務數
,後面括 號中的
mean
表示這是乙個平均值
time per request:
460.381 [ms] (mean)
#每次併發請求時間
(所有併發
)//大家最關心的指標之二,相當於
lr中的
平均事務響應時間
, 後面括號中的
mean
表示這是乙個平均值
time per request:
9.208 [ms] (mean, across all concurrent requests)
#每一請求時間
(併發平均
) //每個請求實際執行時間的平均值
transfer rate:
8771.39 [kbytes/sec] received
#傳輸速 率
//平 均每秒網路上的流量,可以幫助排除是否存在網路流量過大導致響應時間延長的問題
percentage of the requests served within a certain time (ms)
50%
2680
66%
2806
75%
2889
80%
2996
90%
11064
95%
20161
98%
21092
99%
21417
100%
21483 (longest request)
//整個場景中所有請求的響應情況。在場景中每個請求都有乙個響應時間,其 中50%的使用者響應時間小於2680
毫秒,60% 的使用者響應時間小於2806
毫秒,最大的響應時間小於21417
毫秒由於對於併發請求,cpu實際上並不是同時處理的,而是按照每個 請求獲得的時間片逐個輪轉處理的,所以基本上第乙個time per request時間約等於第二個time per request時間乘以併發請求數。
connection times (ms)
#連線時 間
min mean[+/-sd] median max
connect(#
連線):
0 0 2.1
0 46
processing(#
處理):
31 458 94.7
438
1078
waiting(#
等待):
15 437 87.5
422
938total:
31 458 94.7
438
1078
其 它引數
:-n requests
全部請求數
-c concurrency
併發數-t timelimit
最傳等待回應時間
-p postfile
post
數 據檔案
-t content-type post content-type
-v verbosity
how much troubleshooting info to print
-w
print out results 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 normal header lines. (repeatable)
-a attribute
http驗證,
分隔傳遞使用者名稱及密碼
-p attribute
add basic proxy authentication, the attributes
are a colon separated username and password.
-x proxy:port
**伺服器
-v
檢視ab
版本-k
[上述文字**:
在應用ab壓力測試向介面post資料時
d:\xampp\apache\bin>ab -n 1000 -c 100 -t 這裡是post資料檔案 介面url
報錯:ab: could not stat post data file (abtext.txt): partial results are valid but processing is incomplete
在網上找到遇到相同問題的朋友的介紹說ab對post支援不足,在這裡我沒有去深究。採用get行進行的測試結果如下:
d:\xampp\apache\bin>ab -n 1000 -c 100 介面url?資料
ab 壓力測試
apache自帶的ab的壓力測試 以前安裝好apache總是不知道該如何測試apache的效能,現在總算找到乙個測試工具了。就是apache自帶的測試工具ab apache benchmark 在apache的bin目錄下。格式 ab options http hostname port path ...
ab壓力測試
1.我的環境是windows下的phpstudy,進入到apache bin目錄裡面有個ab.exe,壓力測試命令如下 ab.exe c 200 n 1000 2.mysql.php 如下 正常的邏輯思維,壓力增大後,導致資料庫num欄位成為負數,將下面 貼上到自己 下測試即可。在test資料庫下,...
ab壓力測試
ab命令會建立多個併發訪問執行緒,模擬多個訪問者同時對某一url位址進行訪問。它的測試目標是基於url的,因此,它既可以用來測試apache的負載壓力,也可以測試nginx lighthttp tomcat iis等其它web伺服器的壓力。ab命令對發出負載的計算機要求很低,它既不會占用很高cpu,...