文章目錄
- 一、Siege簡介
- 二、安裝步驟
- 0、登錄官網檢查確認最新版本
- 1、下載軟體包
- 2、解壓軟體包
- 3、編譯安裝
- 4、查看命令
- 5、獲取命令幫助
- 三、使用說明
- 1、使用語法
- 2、引數說明
- 3、使用示例
- 1)、查看siege配置
- 2)、查看工具版本
- 3)、獲取指定URL的Header資訊
- 4)、并發1000測驗1000
- 5)、并發100用戶測驗指定檔案中的url
- 6)、并發100測驗60秒
- 四、測驗結果說明
- 五、QA
- 1、配置1000并發用戶測驗是報錯
一、Siege簡介
??Siege是一個http/ftp負載測驗工具和基準測驗工具,它是為開發人員和管理員設計的,用于測量其應用程式在負載下的性能,它可以向服務器發送可配置數量的并發請求,Siege是一款開源的壓力測驗工具,設計用于評估WEB應用在壓力下的承受能力,可以根據配置對一個WEB站點進行多用戶的并發訪問,記錄每個用戶所有請求程序的相應時間,并在一定數量的并發訪問下重復進行,siege可以從您選擇的預置串列中請求隨機的URL,所以siege可用于仿真用戶請求負載,
二、安裝步驟
0、登錄官網檢查確認最新版本
登錄官網siege官網查看siege軟體最新版本,當前最新版本為4.1.1(截止至2021年9月1日)

1、下載軟體包
點擊上一步中版本鏈接下載,
或者直接在Linux服務器上下載,
[root@test1 opt]# wget http://download.joedog.org/siege/siege-4.1.1.tar.gz
2、解壓軟體包
[root@test1 local]# tar -zxvf siege-4.1.1.tar.gz
3、編譯安裝
[root@test1 local]# cd siege-4.1.1/
[root@test1 siege-4.1.1]# ./configure
…
--------------------------------------------------------
Configuration is complete
Run the following commands to complete the installation:
make
make install
For complete documentation: http://www.joedog.org
--------------------------------------------------------
[root@test1 siege-4.1.1]# make && make install
…
make[2]: Leaving directory `/usr/local/siege-4.1.1/html’
make[1]: Leaving directory `/usr/local/siege-4.1.1/html’
4、查看命令
[root@test1 siege-4.1.1]# which siege
/usr/local/bin/siege
5、獲取命令幫助
[root@test1 siege-4.1.1]# siege --help
三、使用說明
1、使用語法
siege [引數] url
url檔案就是一個文本,文本中每行是一個url,
2、引數說明
| 引數 | 引數說明 |
|---|---|
| -V, --version | 版本,列印版本號, |
| -h, --help | 幫助,列印此部分, |
| -C, --config | 配置,顯示當前配置, |
| -v, --verbose | 詳細,將通知列印到螢屏, |
| -q, --quiet | 安靜關閉冗余并抑制輸出, |
| -g, --get | 獲取、下拉HTTP頭并顯示,適合應用程式除錯 |
| -p, --print | 列印,就像只獲取一樣,它列印整個頁面, |
| -c, --concurrent=NUM | 并發用戶,默認值為10 |
| -r, --reps=NUM | 重復次數,運行測驗的次數, |
| -t, --time=NUMm | 定時測驗,其中“m”是修飾符S、m或H ; ex:–時間=1H,一小時試驗, |
| -d, --delay=NUM | 時間延遲,每個請求前的隨機延遲 |
| -b, --benchmark | 基準測驗:請求之間沒有延遲, |
| -i, --internet | 互聯網用戶模擬,隨機點擊網址, |
| -f, --file=FILE | 檔案,選擇特定的URL檔案, |
| -R, --rc=FILE | RC,指定一個siegerc檔案 |
| -l, --log[=FILE] | 記錄到檔案,如果未指定檔案,則使用默認值:前綴/var/seake.log |
| -m, --mark=“text” | 標記,用字串標記日志檔案, 介于.001和NUM之間(不計入統計資料) |
| -H, --header=“text” | 向請求添加標頭(可以是多個) |
| -A, --user-agent=“text” | 在請求中設定用戶代理 |
| -T, --content-type=“text” | 設定請求中的內容型別 |
| -j, --json-output | JSON輸出,將最終統計資料作為JSON列印到標準輸出 |
| –no-parser | 沒有決議器,請關閉HTML頁面決議器 |
| –no-follow | 不跟隨,不跟隨HTTP重定向 |
3、使用示例
1)、查看siege配置
[root@test1 ~]# siege --config
[alert] Zip encoding disabled; siege requires zlib support to enable it
CURRENT SIEGE CONFIGURATION
Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.1
Edit the resource file to change the settings.
----------------------------------------------
version: 4.1.1
verbose: true
color: true
quiet: false
debug: false
protocol: HTTP/1.1
HTML parser: enabled
get method: HEAD
connection: close
concurrent users: 25
time to run: n/a
repetitions: n/a
socket timeout: 30
cache enabled: false
accept-encoding: *
delay: 0.000 sec
internet simulation: false
benchmark mode: false
failures until abort: 1024
named URL: none
URLs file: /usr/local/etc/urls.txt
thread limit: 255
logging: false
log file: /usr/local/var/log/siege.log
resource file: /root/.siege/siege.conf
timestamped output: false
comma separated output: false
allow redirects: true
allow zero byte data: true
allow chunked encoding: true
upload unique files: true
json output: false
no-follow:
- ad.doubleclick.net
- pagead2.googlesyndication.com
- ads.pubsqrd.com
- ib.adnxs.com
proxy auth:
www auth:
2)、查看工具版本
[root@test1 ~]# siege --version
[alert] Zip encoding disabled; siege requires zlib support to enable it
SIEGE 4.1.1
Copyright ? 2021 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)、獲取指定URL的Header資訊
[root@test1 ~]# siege -g http://www.baidu.com
[alert] Zip encoding disabled; siege requires zlib support to enable it
HEAD / HTTP/1.0
Host: www.baidu.com
Accept: /
Accept-Encoding: *
User-Agent: Mozilla/5.0 (pc-x86_64-linux-gnu) Siege/4.1.1
Connection: close
HTTP/1.0 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Thu, 09 Sep 2021 07:12:50 GMT
Etag: “575e1f6f-115”
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Transactions: 1 hits
Availability: 100.00 %
Elapsed time: 0.04 secs
Data transferred: 0.00 MB
Response time: 0.04 secs
Transaction rate: 25.00 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 1.00
Successful transactions: 1
Failed transactions: 0
Longest transaction: 0.04
Shortest transaction: 0.04
4)、并發1000測驗1000
[root@test1 ~]# siege -c1000 -r10000 http://192.168.0.213:8098/dist/#/index?id=a3178a9b829e7dfef4668fddc68fc5ab
5)、并發100用戶測驗指定檔案中的url
[root@test1 tmp]# cat testurl.txt
http://192.168.0.213:8098/dist/#/index?id=a3178a9b829e7dfef4668fddc68fc5ab
http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
http://192.168.0.213:8098/dist/#/index?id=40f123f28dfd968652f6a61556c986b2
[root@test1 tmp]# siege -c100 -r1000 -f testurl.txt
6)、并發100測驗60秒
[root@test1 tmp]# siege -c100 -t 60S http://192.168.0.213:8098/dist/#/index?id=40f123f28dfd968652f6a61556c986b2
…
Lifting the server siege…
Transactions: 29264 hits
Availability: 100.00 %
Elapsed time: 59.70 secs
Data transferred: 295.88 MB
Response time: 0.17 secs
Transaction rate: 490.18 trans/sec
Throughput: 4.96 MB/sec
Concurrency: 85.12
Successful transactions: 29264
Failed transactions: 0
Longest transaction: 12.06
Shortest transaction: 0.00
四、測驗結果說明
Transactions: 34925 hits (處理次數,本次處理了34925此請求)
Availability: 100.00 % (可用性/成功次數的百分比,比如本次100%成功)
Elapsed time: 34.83 secs (運行時間,本次總消耗34.83秒)
Data transferred: 353.18 MB (資料傳送量)
Response time: 0.83 secs(回應時間)
Transaction rate: 1002.73 trans/sec (處理請求頻率,每秒鐘處理8.89次請求)
Throughput: 10.14 MB/sec (吞吐量,傳輸速度)
Concurrency: 833.76 (實際最高并發連接數)
Successful transactions: 34931(成功的傳輸次數)
Failed transactions: 0 (失敗的傳輸次數)
Longest transaction: 30.86 (處理傳輸是所花的最長時間)
Shortest transaction: 0.01(處理傳輸是所花的最短時間)
五、QA
1、配置1000并發用戶測驗是報錯
- 報錯資訊

- 解決方案
[root@test1 ~]# vim /root/.siege/siege.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/299165.html
標籤:其他




