天天看點

siege壓力測試工具安裝和介紹前言目錄1.siege介紹2.siege安裝3.siege使用

前言

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

目錄

  • 前言
  • 目錄
  • siege介紹
  • siege安裝
  • 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測試無法展現出具體細節,我本人也并不是測試人員,後續做并發時候會再找找有沒有更好用的測試軟體推薦給大家.大家有什麼好用的推薦給我哈.

繼續閱讀