常見(jiàn)的壓力測(cè)試工具有很多删豺,在本文就簡(jiǎn)單介紹一下Siege 桑寨。Siege是Linux/Unix下的一個(gè)WEB系統(tǒng)的壓力測(cè)試工具番甩。
下載與安裝:
下載地址: http://download.joedog.org/siege/ ? ?可根據(jù)需要下載版本
$ wget http://download.joedog.org/siege/siege-latest.tar.gz
$ tar zxf siege-latest.tar.gz ? ? ?解壓安裝
$ cd siege-4.0.2/ ? ? ?進(jìn)入安裝路徑下
$ ./configure ? ? ?配置安裝路徑(默認(rèn)路徑)
$ sudo make ? ? 編譯
$ sudo make install? ? ? 編譯安裝
查看是否安裝成功:
查看siege安裝路徑:
$ which siege
/usr/local/bin/siege
查看siege版本:
$ siege -V
SIEGE 4.0.2
參數(shù)說(shuō)明:
可以使用"siege -h"命令來(lái)查看幫助信息:
$ siege -h
SIEGE 4.0.2 ? ? 版本號(hào)
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.
-q, --quiet ? ?QUIET turns verbose off and suppresses output.
-g, --get ? ? GET, pull down HTTP headers and display the
? ? ? transaction. Great for application debugging.
-c, --concurrent=NUM ?CONCURRENT users, default is 10
-r, --reps=NUM ? REPS, number of times to run the test.
-t, --time=NUMm ? TIMED testing where "m" is modifier S, M, or H
? ? ? ex: --time=1H, one hour test.
-d, --delay=NUM ? Time DELAY, random delay before each requst
-b, --benchmark ? BENCHMARK: no delays between requests.
-i, --internet ? INTERNET user simulation, hits URLs randomly.
-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.
? ? ? between .001 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
-T, --content-type="text" Sets Content-Type in request
查看當(dāng)前的配置信息
$ siege -C
使用說(shuō)明:
(1) 直接請(qǐng)求URL:
$ siege -c 20 -r 10 http://www.cnwytnet.com
參數(shù)說(shuō)明: -c 是并發(fā)量赡麦,并發(fā)數(shù)為20人 -r 是重復(fù)次數(shù)猜憎, 重復(fù)10次
(2) 隨機(jī)選取urls.txt中列出所有的網(wǎng)址
在當(dāng)前目錄下創(chuàng)建一個(gè)名為"urls-demo.txt"的文件娩怎。 文件里邊填寫(xiě)URL地址,可以有多條胰柑,每行一條截亦,比如:
# URLs:
http://www.sogou.com/web?query=php&from=wang_yong_tao
https://www.baidu.com/
// 執(zhí)行 $ siege -c 5 -r 10 -f urls-demo.txt
$ siege -c 5 -r 10 -f /Users/WangYoungTom/temp/urls-demo.txt
參數(shù)說(shuō)明: -c 是并發(fā)量,并發(fā)數(shù)為5人 -r 是重復(fù)次數(shù)柬讨, 重復(fù)10次 -f 指定使用文件崩瓤,urls-demo.txt就是一個(gè)文本文件,每行都是一個(gè)url踩官,會(huì)從里面隨機(jī)訪問(wèn)的
Siege從Siege-V2.06起支持POST和GET兩種請(qǐng)求方式却桶。 如果想模擬POST請(qǐng)求,可以在urls-demo.txt中安裝一下格式填寫(xiě)URL:
# URL (POST):
http://wangtest.com/index.php POST UserId=XXX&StartIndex=0&OS=Android&Sign=cff6wyt505wyt4c
http://wangtest.com/articles.php POST UserId=XXX&StartIndex=0&OS=iOS&Sign=cff63w5905wyt4c
使用示例:
請(qǐng)求http://www.cnwytnet.com蔗牡,并發(fā)人數(shù)為10颖系,重復(fù)5次,每次請(qǐng)求間隔3秒
$ siege --concurrent=10 --reps=5 --delay=3 http://www.cnwytnet.com
$ siege -c 10 -r 5 -d 3 http://www.cnwytnet.com
結(jié)果說(shuō)明:
Transactions: 153 hits (處理次數(shù)辩越,本次處理了153此請(qǐng)求)
Availability: 100.00 % (可用性/成功次數(shù)的百分比,比如本次100%成功)
Elapsed time: 17.22 secs (運(yùn)行時(shí)間嘁扼,本次總消耗17.22秒)
Data transferred: 7.70 MB (數(shù)據(jù)傳送量)
Response time: 0.17 secs (響應(yīng)時(shí)間)
Transaction rate: 8.89 trans/sec (處理請(qǐng)求頻率,每秒鐘處理8.89次請(qǐng)求)
Throughput: 0.45 MB/sec (吞吐量,傳輸速度)
Concurrency: 1.54 (實(shí)際最高并發(fā)連接數(shù))
Successful transactions: 153 (成功的傳輸次數(shù))
Failed transactions: 0 (失敗的傳輸次數(shù))
Longest transaction: 0.70 (處理傳輸是所花的最長(zhǎng)時(shí)間)
Shortest transaction: 0.02 (處理傳輸是所花的最短時(shí)間)
使用實(shí)例:
$ siege -c 5 -r 10 http://www.baidu.com
Transactions: ? ?386 hits
Availability: ? ?100.00 %
Elapsed time: ? ?37.40 secs
Data transferred: ? 19.47 MB
Response time: ? ?0.43 secs
Transaction rate: ? 10.32 trans/sec
Throughput: ? ?0.52 MB/sec
Concurrency: ? ?4.45
Successful transactions: ? 386
Failed transactions: ? ?0
Longest transaction: ? 2.38
Shortest transaction: ? 0.02
參考鏈接:
官網(wǎng) https://www.joedog.org/
文檔 https://www.joedog.org/siege-manual/#a01
http://blog.csdn.net/qingye2008/article/details/34500949
內(nèi)容有稍微調(diào)整和修改
[END]