壓力測試工具segie的使用
使用文檔參考地址:https://www.joedog.org/siege-manual/
siege4地址:http://download.joedog.org/siege/
下載程序安裝包:http://download.joedog.org/siege/siege-4.0.2.tar.gz
#解壓縮.tar.gz程序包
tar zxvf siege-4.0.2.tar.gz
#進入主文件目錄
cd siege-4.0.2
#刪除上次產生的obj及可執行文件,如重復安裝,可執行該命令
make clean
#校驗配置和環境信息
./configure --prefix=/opt/siege4
#編譯和安裝
make && make install
siege命令參數
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
參數項使用說明
-c 100 指定並發數 100
-r 10 指定測試次數 10
-f urls.txt 指定url文件
-i internet系統,隨機發送url
-b 請求無需等待 -d NUM 延遲多少秒
-t 5 持續測試5分鍾 -t3600S, -t60M, -t1H
-v 輸出詳細信息
-l 記錄壓測日志信息到指定文件
# -r和-t一般不同時使用
例如:
cd /opt/siege4/bin
./siege -c 10 -r 10 -b -t 10 www.xxx.com
指定http請求頭 文檔類型
./siege -H "Content-Type:application/json" -v -c 10 -r 10 -f urls.txt -i -d 1 -t20s
讀入文件方式:
post中的參數可以放到一個文件,再通過以上方式來使用
./siege -c 2 -r 2 -b -t 10 www.xxx.com post <./purlx.txt
在文件中,可以定義變量。類似shell的方式,使用${}或$()。
host=www.xxx.com http://${host}/index.html
文件urls.txt中的地址:
http://www.xxx.com/index.html
http://www.xxx.com/xxx.jsp
http://www.xxx.com/xxx.do?key=value
http://www.xxx.com/xxx.do post key=value
http://www.xxx.com/xxxx.do post key1=value&key2=value2
結果說明:
Transactions: 總共測試次數
Availability: 成功次數百分比
Elapsed time: 總共耗時多少秒
Data transferred: 總共數據傳輸
Response time: 等到響應耗時
Transaction rate: 平均每秒處理請求數
Throughput: 吞吐率
Concurrency: 最高並發
Successful transactions: 成功的請求數
Failed transactions: 失敗的請求數
1,發送post請求時,url格式為:http://www.xxx.com/ post p1=v1&p2=v2
2,如果url中含有中文和空格,需先進行encode編碼。