天天看點

web伺服器壓力測試工具

web伺服器壓力測試工具

轉載:http://blog.licess.org/http_load-webbench-ab-siege/

web伺服器壓力測試工具

一、http_load

web伺服器壓力測試工具
web伺服器壓力測試工具

程式非常小,解壓後也不到100K

web伺服器壓力測試工具
web伺服器壓力測試工具

http_load以并行複用的方式運作,用以測試web伺服器的吞吐量與負載。但是它不同于大多數壓力測試工

web伺服器壓力測試工具
web伺服器壓力測試工具

具,它可以以一個單一的程序運作,一般不會把客戶機搞死。還可以測試HTTPS類的網站請求。

web伺服器壓力測試工具
web伺服器壓力測試工具

下載下傳位址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz

web伺服器壓力測試工具

安裝很簡單

web伺服器壓力測試工具

#tar zxvf http_load-12mar2006.tar.gz

web伺服器壓力測試工具

#cd http_load-12mar2006

web伺服器壓力測試工具

#make && make install

web伺服器壓力測試工具
web伺服器壓力測試工具

指令格式:http_load    -p 并發通路程序數    -s 通路時間    需要通路的URL檔案

web伺服器壓力測試工具
web伺服器壓力測試工具

參數其實可以自由組合,參數之間的選擇并沒有什麼限制。比如你寫成http_load -parallel 5 -seconds

web伺服器壓力測試工具
web伺服器壓力測試工具

300 urls.txt也是可以的。我們把參數給大家簡單說明一下。

web伺服器壓力測試工具

-parallel 簡寫-p :含義是并發的使用者程序數。

web伺服器壓力測試工具

-fetches 簡寫-f :含義是總計的通路次數

web伺服器壓力測試工具

-rate        簡寫-p :含義是每秒的通路頻率

web伺服器壓力測試工具

-seconds簡寫-s :含義是總計的通路時間

web伺服器壓力測試工具
web伺服器壓力測試工具

準備URL檔案:urllist.txt,檔案格式是每行一個URL,URL最好超過50-100個測試效果比較好.檔案格式

web伺服器壓力測試工具
web伺服器壓力測試工具

如下:

web伺服器壓力測試工具

http://www.vpser.net/uncategorized/choose-vps.html

web伺服器壓力測試工具

http://www.vpser.net/vps-cp/hypervm-tutorial.html

web伺服器壓力測試工具

http://www.vpser.net/coupons/diavps-april-coupons.html

web伺服器壓力測試工具

http://www.vpser.net/security/vps-backup-web-mysql.html

web伺服器壓力測試工具

例如:

web伺服器壓力測試工具
web伺服器壓力測試工具

http_load -p 30 -s 60    urllist.txt

web伺服器壓力測試工具

參數了解了,我們來看運作一條指令來看看它的傳回結果

web伺服器壓力測試工具

指令:% ./http_load -rate 5 -seconds 10 urls說明執行了一個持續時間10秒的測試,每秒的頻率為5。

web伺服器壓力測試工具
web伺服器壓力測試工具

49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds5916 mean bytes/connection4.89274

web伺服器壓力測試工具
web伺服器壓力測試工具

fetches/sec, 28945.5 bytes/secmsecs/connect: 28.8932 mean, 44.243 max, 24.488 minmsecs/first

web伺服器壓力測試工具
web伺服器壓力測試工具

-response: 63.5362 mean, 81.624 max, 57.803 minHTTP response codes: code 200 — 49    

web伺服器壓力測試工具
web伺服器壓力測試工具

結果分析:

web伺服器壓力測試工具

1.49 fetches, 2 max parallel, 289884 bytes, in 10.0148 seconds

web伺服器壓力測試工具

說明在上面的測試中運作了49個請求,最大的并發程序數是2,總計傳輸的資料是289884bytes,運作的時間是10.0148秒

web伺服器壓力測試工具

2.5916 mean bytes/connection說明每一連接配接平均傳輸的資料量289884/49=5916

web伺服器壓力測試工具

3.4.89274 fetches/sec, 28945.5 bytes/sec

web伺服器壓力測試工具

說明每秒的響應請求為4.89274,每秒傳遞的資料為28945.5 bytes/sec

web伺服器壓力測試工具

4.msecs/connect: 28.8932 mean, 44.243 max, 24.488 min說明每連接配接的平均響應時間是28.8932 msecs

web伺服器壓力測試工具
web伺服器壓力測試工具

,最大的響應時間44.243 msecs,最小的響應時間24.488 msecs

web伺服器壓力測試工具

5.msecs/first-response: 63.5362 mean, 81.624 max, 57.803 min

web伺服器壓力測試工具

6、HTTP response codes: code 200 — 49         說明打開響應頁面的類型,如果403的類型過多,那可能

web伺服器壓力測試工具
web伺服器壓力測試工具

要注意是否系統遇到了瓶頸。

web伺服器壓力測試工具

特殊說明:

web伺服器壓力測試工具

測試結果中主要的名額是 fetches/sec、msecs/connect 這個選項,即伺服器每秒能夠響應的查詢次數,

web伺服器壓力測試工具
web伺服器壓力測試工具

用這個名額來衡量性能。似乎比 apache的ab準确率要高一些,也更有說服力一些。

web伺服器壓力測試工具

Qpt-每秒響應使用者數和response time,每連接配接響應使用者時間。

web伺服器壓力測試工具

測試的結果主要也是看這兩個值。當然僅有這兩個名額并不能完成對性能的分析,我們還需要對伺服器的

web伺服器壓力測試工具
web伺服器壓力測試工具

cpu、men進行分析,才能得出結論

web伺服器壓力測試工具
web伺服器壓力測試工具
web伺服器壓力測試工具
web伺服器壓力測試工具

二、webbench

web伺服器壓力測試工具
web伺服器壓力測試工具

webbench是Linux下的一個網站壓力測試工具,最多可以模拟3萬個并發連接配接去測試網站的負載能力。下載下傳位址可以到google搜,我這裡給出一個

web伺服器壓力測試工具

下載下傳位址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz

web伺服器壓力測試工具

這個程式更小,解壓後不到50K,呵呵

web伺服器壓力測試工具

安裝非常簡單

web伺服器壓力測試工具

#tar zxvf webbench-1.5.tar.gz

web伺服器壓力測試工具

#cd webbench-1.5

web伺服器壓力測試工具
web伺服器壓力測試工具

會在目前目錄生成webbench可執行檔案,直接可以使用了

web伺服器壓力測試工具
web伺服器壓力測試工具

用法:

web伺服器壓力測試工具
web伺服器壓力測試工具

webbench -c 并發數 -t 運作測試時間 URL

web伺服器壓力測試工具

如:

web伺服器壓力測試工具

webbench -c 5000 -t 120 http://www.vpser.net

web伺服器壓力測試工具
web伺服器壓力測試工具

三、ab

web伺服器壓力測試工具

ab是apache自帶的一款功能強大的測試工具

web伺服器壓力測試工具

安裝了apache一般就自帶了,

web伺服器壓力測試工具

用法可以檢視它的說明

web伺服器壓力測試工具
web伺服器壓力測試工具

$ ./ab

web伺服器壓力測試工具

./ab: wrong number of arguments

web伺服器壓力測試工具

Usage: ./ab [options] [http://]hostname[:port]/path

web伺服器壓力測試工具

Options are:

web伺服器壓力測試工具

-n requests Number of requests to perform

web伺服器壓力測試工具

-c concurrency Number of multiple requests to make

web伺服器壓力測試工具

-t timelimit Seconds to max. wait for responses

web伺服器壓力測試工具

-p postfile File containing data to POST

web伺服器壓力測試工具

-T content-type Content-type header for POSTing

web伺服器壓力測試工具

-v verbosity How much troubleshooting info to print

web伺服器壓力測試工具

-w Print out results in HTML tables

web伺服器壓力測試工具

-i Use HEAD instead of GET

web伺服器壓力測試工具

-x attributes String to insert as table attributes

web伺服器壓力測試工具

-y attributes String to insert as tr attributes

web伺服器壓力測試工具

-z attributes String to insert as td or th attributes

web伺服器壓力測試工具

-C attribute Add cookie, eg. ‘Apache=1234. (repeatable)

web伺服器壓力測試工具

-H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip’

web伺服器壓力測試工具

Inserted after all normal header lines. (repeatable)

web伺服器壓力測試工具

-A attribute Add Basic WWW Authentication, the attributes

web伺服器壓力測試工具

are a colon separated username and password.

web伺服器壓力測試工具

-P attribute Add Basic Proxy Authentication, the attributes

web伺服器壓力測試工具
web伺服器壓力測試工具

-X proxy:port Proxyserver and port number to use

web伺服器壓力測試工具

-V Print version number and exit

web伺服器壓力測試工具

-k Use HTTP KeepAlive feature

web伺服器壓力測試工具

-d Do not show percentiles served table.

web伺服器壓力測試工具

-S Do not show confidence estimators and warnings.

web伺服器壓力測試工具

-g filename Output collected data to gnuplot format file.

web伺服器壓力測試工具

-e filename Output CSV file with percentages served

web伺服器壓力測試工具

-h Display usage information (this message)

web伺服器壓力測試工具

參數衆多,一般我們用到的是-n 和-c

web伺服器壓力測試工具
web伺服器壓力測試工具

./ab -c 1000 -n 100 http://www.vpser.net/index.php

web伺服器壓力測試工具
web伺服器壓力測試工具

這個表示同時處理1000個請求并運作100次index.php檔案.

web伺服器壓力測試工具

四、Siege

web伺服器壓力測試工具

一款開源的壓力測試工具,可以根據配置對一個WEB站點進行多使用者的并發通路,記錄每個使用者所有請求過程的相應時間,并在一定數量的并發通路下重複進行。

web伺服器壓力測試工具

官方:http://www.joedog.org/

web伺服器壓力測試工具

Siege下載下傳:http://soft.vpser.net/test/siege/siege-2.67.tar.gz

web伺服器壓力測試工具

解壓:

web伺服器壓力測試工具

# tar -zxf siege-2.67.tar.gz

web伺服器壓力測試工具

進入解壓目錄:

web伺服器壓力測試工具

# cd siege-2.67/

web伺服器壓力測試工具

安裝:

web伺服器壓力測試工具

#./configure ; make

web伺服器壓力測試工具

#make install

web伺服器壓力測試工具
web伺服器壓力測試工具

使用

web伺服器壓力測試工具

siege -c 200 -r 10 -f example.url

web伺服器壓力測試工具

-c是并發量,-r是重複次數。 url檔案就是一個文本,每行都是一個url,它會從裡面随機通路的。

web伺服器壓力測試工具
web伺服器壓力測試工具

example.url内容:

web伺服器壓力測試工具
web伺服器壓力測試工具

http://www.licess.cn

web伺服器壓力測試工具

http://www.vpser.net

web伺服器壓力測試工具

http://soft.vpser.net

web伺服器壓力測試工具
web伺服器壓力測試工具

結果說明

web伺服器壓力測試工具

Lifting the server siege… done.

web伺服器壓力測試工具

Transactions: 3419263 hits //完成419263次處理

web伺服器壓力測試工具

Availability: 100.00 % //100.00 % 成功率

web伺服器壓力測試工具

Elapsed time: 5999.69 secs //總共用時

web伺服器壓力測試工具

Data transferred: 84273.91 MB //共資料傳輸84273.91 MB

web伺服器壓力測試工具

Response time: 0.37 secs //相應用時1.65秒:顯示網絡連接配接的速度

web伺服器壓力測試工具

Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次處理:表示伺服器後

web伺服器壓力測試工具

Throughput: 14.05 MB/sec //平均每秒傳送資料

web伺服器壓力測試工具

Concurrency: 213.42 //實際最高并發數

web伺服器壓力測試工具

Successful transactions: 2564081 //成功處理次數

web伺服器壓力測試工具

Failed transactions: 11 //失敗處理次數

web伺服器壓力測試工具

Longest transaction: 29.04 //每次傳輸所花最長時間

web伺服器壓力測試工具

Shortest transaction: 0.00 //每次傳輸所花最短時間

繼續閱讀