1. 程式人生 > >siege壓力測試工具安裝和介紹

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

前言

最近公司有個專案需要做一個短輪詢類推送伺服器(推送伺服器分為三種,短輪詢,長輪詢,長連線),使用者量不大,但是為了保險起見還是做一下壓力測試.用的工具是siege.

目錄

1.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安裝

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端的介面併發情況.

  • 請求型別 : 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測試無法體現出具體細節,我本人也並不是測試人員,後續做併發時候會再找找有沒有更好用的測試軟體推薦給大家.大家有什麼好用的推薦給我哈.