Siege 是Linux/Unix下的一個WEB系統的壓力測試工具。php
下載地址: http://download.joedog.org/siege/ 目前最新版本是 2016-05-20 發佈的 siege-4.0.2.tar.gzweb
$ wget http://download.joedog.org/siege/siege-latest.tar.gz $ tar zxf siege-latest.tar.gz $ cd siege-4.0.2/ $ ./configure $ sudo make $ sudo make install
查看是否安裝成功:併發
查看siege安裝路徑: $ which siege /usr/local/bin/siege 查看siege版本: $ siege -V SIEGE 4.0.2
能夠使用"siege -h"命令來查看幫助信息:app
$ siege -h SIEGE 4.0.2 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
查看當前的配置信息 $ siege -C
(1) 直接請求URL:dom
$ siege -c 20 -r 10 http://www.cnwytnet.com
參數說明: -c 是併發量,併發數爲20人 -r 是重複次數, 重複10次高併發
(2) 隨機選取urls.txt中列出全部的網址工具
在當前目錄下建立一個名爲"urls-demo.txt"的文件。 文件裏邊填寫URL地址,能夠有多條,每行一條,好比:測試
# URLs: http://www.sogou.com/web?query=php&from=wang_yong_tao https://www.baidu.com/
// 執行 $ siege -c 5 -r 10 -f urls-demo.txt $ siege -c 5 -r 10 -f /Users/WangYoungTom/temp/urls-demo.txtui
參數說明: -c 是併發量,併發數爲5人 -r 是重複次數, 重複10次 -f 指定使用文件,urls-demo.txt就是一個文本文件,每行都是一個url,會從裏面隨機訪問的this
Siege從Siege-V2.06起支持POST和GET兩種請求方式。 若是想模擬POST請求,能夠在urls-demo.txt中安裝一下格式填寫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
使用示例:
// 請求http://www.cnwytnet.com,併發人數爲10,重複5次,每次請求間隔3秒 $ siege --concurrent=10 --reps=5 --delay=3 http://www.cnwytnet.com $ siege -c 10 -r 5 -d 3 http://www.cnwytnet.com
Transactions: 153 hits (處理次數,本次處理了153此請求)
Availability: 100.00 % (可用性/成功次數的百分比,好比本次100%成功)
Elapsed time: 17.22 secs (運行時間,本次總消耗17.22秒)
Data transferred: 7.70 MB (數據傳送量)
Response time: 0.17 secs (響應時間)
Transaction rate: 8.89 trans/sec (處理請求頻率,每秒鐘處理8.89次請求)
Throughput: 0.45 MB/sec (吞吐量,傳輸速度)
Concurrency: 1.54 (實際最高併發鏈接數)
Successful transactions: 153 (成功的傳輸次數)
Failed transactions: 0 (失敗的傳輸次數)
Longest transaction: 0.70 (處理傳輸是所花的最長時間)
Shortest transaction: 0.02 (處理傳輸是所花的最短期)
$ 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
文檔 https://www.joedog.org/siege-manual/#a01
http://blog.csdn.net/qingye2008/article/details/34500949
[END]