siege壓力測試工具安裝和介紹


1.siege介紹

siege介紹 : 百度百科 : siege

輸入參數說明

輸入名稱 解釋說明
-V, –version 打印版本信息
-h, –help 打印幫助信息
-C, –config 顯示配置信息
-v, –verbose 打印冗余配置信息。
-g, –get 顯示HTTP交易。
-c, –concurrent=NUM 設置並發用戶數
-u, –url=”URL” 設置被測Web的URL
-i, –internet 用戶模擬、隨機訪問URL
-b, –benchmark . 基准測試。
-t, –time=NUM 設置測試時間。
-r, –reps=NUM 設置測試次數
-f, –file=FILE 更改配置文件存檔
-R, –rc=FILE 更改siegerc文件和環境變量
-l, –log 測試日志
-m, –mark=”text” 標記測試日志
-d, –delay=NUM 設置時間延遲
-H, –header=”text” 增加測試頭文件
-A, –user-agent=”text” 設置代理測試請求

輸出參數說明:

輸出名稱 解釋說明
Transactions: 訪問次數
Availability: 成功次數
Elapsed time: 測試用時
Data transferred: 測試傳輸數據量
Response time: 平均響應時間
Transaction rate: 每秒事務處理量
Throughput: 吞吐率
Concurrency: 並發用戶數
Successful transactions: 成功傳輸次數
Failed transactions: 失敗傳輸次數
Longest transaction: 最長響應時間
Shortest transaction: 最短響應時間

2.siege安裝

下載地址 : http://download.joedog.org/siege/ , 我用的版本 : siege-2.70.tar.gz

CaodeMacBook-Pro:local root# tar -xzvf siege-2.70.tar 
CaodeMacBook-Pro:local root# cd siege-2.70
CaodeMacBook-Pro:siege-2.70 root# ./configure
CaodeMacBook-Pro:siege-2.70 root# make 
CaodeMacBook-Pro:siege-2.70 root# make install

安裝成功驗證 :

CaodeMacBook-Pro:siege-2.70 root# siege -version
siege: invalid option -- e
siege: invalid option -- e
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.

3.siege使用

我這邊是測試了一個server端的接口並發情況.

  • 接口地址是:http://118.212.149.xx:8080/xx/xx/xx
  • 請求類型 : POST
  • 請求參數 : {“accountId”:”123”,”platform”:”ios”}
  • 請求次數 :10次
  • 請求並發數量 : 200

請求 : (請求參數說明請參照上文中表格)

CaodeMacBook-Pro:siege-2.70 root# siege "http://118.212.149.xx:8080/xx/xx/xx POST {\"accountId\":\"123\",\"platform\":\"ios\"}" -r 10 -c 200

返回 : (返回參數說明請參照上文中表格)

done.
Transactions:               2000 hits
Availability:             100.00 %
Elapsed time:              15.27 secs
Data transferred:           0.07 MB
Response time:              0.47 secs
Transaction rate:         130.98 trans/sec
Throughput:             0.00 MB/sec
Concurrency:               61.45
Successful transactions:        2000
Failed transactions:               0
Longest transaction:            8.17
Shortest transaction:           0.06

 

常用的siege命令舉例

# 200個並發對http://www.google.com發送請求100次
siege -c 200 -r 100 http://www.google.com

# 在urls.txt中列出所有的網址 siege -c 200 -r 100 -f urls.txt

# 隨機選取urls.txt中列出所有的網址 siege
-c 200 -r 100 -f urls.txt -i

# delay
=0,更准確的壓力測試,而不是功能測試 siege -c 200 -r 100 -f urls.txt -i -b

# 指定http請求頭 文檔類型 siege
-H "Content-Type:application/json" -c 200 -r 100 -f urls.txt -i -b

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM