三種web性能壓力測試工具http_load webbench apache benc

題記:壓力和性能測試工具很多,下文討論的是我覺得比較容易上手,用的比較多的三種


http_load

下載地址:http://www.acme.com/software/http_load/http_load-12mar2006.tar.gz

程序非常小,解壓後也不到100K 居家旅行 攜帶方便 呵呵

http_load以並行複用的方式運行,用以測試web服務器的吞吐量與負載。但是它不同於大多數壓力測試工具,它可以以一個單一的進程運行,一般不會把客戶機搞死。可以可以測試HTTPS類的網站請求。

命令格式:http_load  -p 併發訪問進程數  -s 訪問時間  需要訪問的URL文件
例如:

引用
http_load -p 30 -s 60  urllist.txt準備URL文件:tst.list,文件格式是每行一個URL,URL最好超過50-100個測試效果比較好,另外,測試 結果中主要的指標是 fetches/sec 這個選項,即服務器每秒能夠響應的查詢次數,用這個指標來衡量性能。似乎比 apache的ab準確率要高一些,也更有說服力一些。

官方的例子:


引用

% ./http_load -rate 10 -seconds 60 urllist.txt
49 fetches, 4 max parallel, 289884 bytes, in 10.0148 seconds
5916 mean bytes/connection
4.89274 fetches/sec, 28945.5 bytes/sec
msecs/connect: 28.8932 mean, 44.243 max, 24.488 min
msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min

4.89274 fetches/sec 這個值得就是說服務器每秒能夠響應的查詢次數爲4.8左右
這個值得是根據 49 fetches / 10.0148 seconds 秒計算出來的



webbench

webbench是Linux下的一個網站壓力測試工具,最多可以模擬3萬個併發連接去測試網站的負載能力。下載地址可以到baidu google搜,我這裏給出一個
下載地址:http://cid-9601b7b7f2063d42.skydrive.live.com/self.aspx/Public/webbench-1.5.tar.gz
這個程序更小,解壓後不到50K,呵呵
安裝非常簡單
#tar zxvf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install
會在當前目錄生成webbench可執行文件,直接可以使用了

用法:

webbench -c 併發數 -t 運行測試時間 URL
如:
webbench -c 5000 -t 120 http://www.askwan.com



ab 
ab是apache自帶的一款功能強大的測試工具
安裝了apache一般就自帶了,
用法可以查看它的說明


引用
$ ./ab
./ab: wrong number of arguments
Usage: ./ab [options] [http://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-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 Add cookie, eg. 'Apache=1234. (repeatable)
-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.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-h Display usage information (this message)

參數衆多,一般我們用到的是-n 和-c
例如:
./ab -c 1000 -n 100 http://www.askwan.com/index.php

這個表示同時處理1000個請求並運行100次index.php文件.


結果分析 ( 後面顏色字爲中文翻譯 ): 
Server Software:        Apache/2.0.55 
Server Hostname:        localhost 
Server Port:            80 
Document Path:          /1.php 
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:           0 
Total transferred:      827019400 bytes   # 總傳輸大小 
HTML transferred:       825219400 bytes 
Requests per second:    108.61 [#/sec] (mean)   # 每秒請求數 ( 平均 ) 
Time per request:       460.381 [ms] (mean)   # 每次併發請求時間 ( 所有併發 ) 
Time per request:       9.208 [ms] (mean, across all concurrent requests)   # 每一請求時間 ( 併發平均 )   
Transfer rate:          8771.39 [Kbytes/sec] received    # 傳輸速率 
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     938 
Total:         31  458  94.7    438    1078 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章