Web壓力測試工具Siege介紹

Siege是我所用過的一款不錯的網站壓力測試工具,它能夠很是容易地定製併發訪問人數以及併發時間,安裝、使用也很是方便,固然它是在Linux環境下使用的,下面來對它做一個介紹。併發

官方網址:http://www.joedog.org/app

下載網址:ftp://ftp.joedog.org/pub/,進入到ftp://ftp.joedog.org/pub/siege/下載最新版:dom

siege-2.70.tar.gz工具

測試

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

./configurethis

makeurl

make installspa

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

輸入: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/

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

使用:

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

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

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

新建一個文件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網址。

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

Lifting the server siege…      done.

Transactions:                   7555 hits

Availability:                  99.47 %

Elapsed time:                 299.92 secs

Data transferred:              99.17 MB

Response time:                  7.30 secs

Transaction rate:              25.19 trans/sec

Throughput:                     0.33 MB/sec

Concurrency:                  183.84

Successful transactions:        7555

Failed transactions:              40

Longest transaction:           17.94

Shortest transaction:           0.02

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

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

相關文章
相關標籤/搜索