Web壓力測試工具Siege

Siege是我所用過的一款不錯的網站壓力測試工具,它可以非常容易地定製併發訪問人數以及併發時間,安裝、使用也非常方便,當然它是在Linux環境下使用的 官方網址:http://www.joedog.org/

安裝解壓:tar -zxvf siege-2.70.tar.gz,進入到解壓後的目錄:siege-2.70,運行命令:

./configure

make

make install

安裝完畢後如果有錯誤,則按照提示信息處理即可(有可能會出現錯誤,我安裝的時候就報了錯,不過有很清楚地提示信息)。

修改siege配置文件
  # vi ~/.siegerc 
  回車後,siege的配置文件顯示出來,將要修改的關鍵字進行修改
  主要修改
verbose=false
concurrent=50
delay
=1
internet
=true
benchmark
=true

輸入:siege –help,如果安裝沒問題會出現以下類似信息:

SIEGE 2.70

Usage: siege [options]

siege [options] URL

siege -g URL

Options:

-V, –version           VERSION, prints the version number.

-h, –help              HELP, prints this section.

-C, –config            CONFIGURATION, show the current config.

-v, –verbose           VERBOSE, prints notification to screen.

-g, –get               GET, pull down HTTP headers and display the

transaction. Great for application debugging.

-c, –concurrent=NUM    CONCURRENT users, default is 10

-i, –internet          INTERNET user simulation, hits URLs randomly.

-b, –benchmark         BENCHMARK: no delays between requests.

-t, –time=NUMm         TIMED testing where “m” is modifier S, M, or H

ex: –time=1H, one hour test.

-r, –reps=NUM          REPS, number of times to run the test.

-f, –file=FILE         FILE, select a specific URLS FILE.

-R, –rc=FILE           RC, specify an siegerc file

-l, –log[=FILE]        LOG to FILE. If FILE is not specified, the

default is used: PREFIX/var/siege.log

-m, –mark=”text”       MARK, mark the log file with a string.

-d, –delay=NUM         Time DELAY, random delay before each requst

between 1 and NUM. (NOT COUNTED IN STATS)

-H, –header=”text”     Add a header to request (can be many)

-A, –user-agent=”text” Sets User-Agent in request

Copyright (C) 2010 by Jeffrey Fulmer, et al.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.

上面也是運行的一些參數,右邊是對一些參數的解釋說明

比如:

–C :查看siege當前的配置信息

–V:版權說明信息

–c:並行啓動(訪問)用戶數,默認是10

-t:壓力測試時間,比如-t5表示持續時間是5分鐘

-r:每個連接發出的請求數量,這個與t有些類似,所以設置了這個值就不需要設置t了,反之亦然。

-f:對應一個文件,這個文件裏每一行爲一個URL鏈接,格式如:

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/2010/12/14/2806/

好了,主要的一些參數說明就介紹這麼多,其餘的可以參考上面的英文。

使用:

1、  啓動100個用戶(線程)在5分鐘內對某一頁面www.zihou.me進行併發訪問

siege http://www.zihou.me -c200 -t5

2、  對多個頁面進行併發訪問

新建一個文件urls,裏面的內容爲(只是例子,任何url都可以):

http://www.zihou.me

http://www.zihou.me/2010/12/16/2821/

http://www.zihou.me/2010/12/14/2806/

siege -f urls -c200 -t5

表示啓動200個用戶在5分鐘內併發訪問以上的url網址。

併發測試完畢後,會打印出一些結果信息:

Transactions: 25000 hits  意思是總共完成了25000次測試


  Availability: 100.00 %  測試的有效性100%


  Elapsed time: 65.52 secs  用時65.52秒


  Data transferred: 83.65 MB  傳輸了83.65MB數據


  Response time: 0.57 secs  響應時間


  Transaction rate: 381.56 trans/sec  每秒381.56次交易


  Throughput: 1.28 MB/sec  數據吞吐量每秒1.28MB


  Concurrency: 216.02  實際併發訪問


  Successful transactions: 21707  成功的交易


  Failed transactions: 0  失敗的交易


  Longest transaction: 5.83  交易最長時間


  Shortest transaction: 0.00  交易最短時間


  另外,提醒一句,如果你的WEB服務器用的是Apache,請不要將併發數設爲大於200。

如果在併發的過程中,被訪問的頁面打開出錯或及其緩慢,表示在當前併發條件下,被訪問網站是不能承受的,也就是抗併發能力弱。

另外,在併發的過程中最好通過top命令來查看CPU和Memory的佔用情況。



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