1. 程式人生 > >linux系統裏模擬並發請求siege

linux系統裏模擬並發請求siege

linux系統裏模擬並發請求siege

siege壓力測試,siege會將接口進行模擬並發,返回每秒的並發數!

一、siege的安裝
下載:wget
一、siege的安裝
下載:wget http://download.joedog.org/siege/siege-latest.tar.gz http://www.joedog.org/pub/siege/siege-latest.tar.gz
解壓: tar -zxvf siege-latest.tar.gz
cd siege-..*
./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/ssl

mkdir -p /usr/local/siege/etc
mkdir -p /usr/local/siege/var
make
make install

查看配置文件
/usr/local/siege/bin/siege -C

二、siege的使用
舉例說明:

50個用戶(每次並發量)重復100次 共產生 50*100 個請求
/usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com

50個用戶 重復100次 發送GET參數
/usr/local/siege/bin/siege -c 50 -r 100  http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=60

50個用戶 重復100次 發送POST參數 (註意引號)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST name=zhangsan"

50個用戶 重復100次 發送POST參數(從文件中讀取)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST < /root/ab_test/post.xml"

另外還有挺多參數
詳情請man 或 siege -h

siege報表解析,請man查看,暫略(有點累了,不想寫了。。。。。)。
Transactions:                     10 hits    :服務器接收的請求數
Availability:                 100.00 %       :有效情況的比例
Elapsed time:                   1.06 secs    :  測試所用的時間
Data transferred:               0.04 MB    :每個模擬用戶的數據傳輸量
Response time:                  0.03 secs    :響應每個模擬用戶請求的平均時間
Transaction rate:               9.43 trans/sec    :服務器每秒處理事務的平均數
Throughput:                     0.04 MB/sec    :服務器每秒跟所有模擬用戶的數據傳輸量
Concurrency:                    0.25    :每秒的模擬連接
Successful transactions:          10    :處理成功的事務數(code<400)
Failed transactions:               0    : 處理失敗的事務數(code>400)
Longest transaction:            0.04    :最長的事務處理時間
Shortest transaction:           0.02    :最短的事務處理時間

siege -c 200 -r 10 -f example.url
-c是並發量,-r是重復次數。 url文件就是一個文本,每行都是一個url,它會從裏面隨機訪問的。

example.url內容:

http://www.licess.cn
http://www.vpser.net
http://soft.vpser.net

結果說明
Lifting the server siege… done.
Transactions: 3419263 hits //完成419263次處理
Availability: 100.00 % //100.00 % 成功率
Elapsed time: 5999.69 secs //總共用時
Data transferred: 84273.91 MB //共數據傳輸84273.91 MB

Response time: 0.37 secs //相應用時1.65秒:顯示網絡連接的速度
Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次處理:表示服務器後
Throughput: 14.05 MB/sec //平均每秒傳送數據
Concurrency: 213.42 //實際最高並發數
Successful transactions: 2564081 //成功處理次數
Failed transactions: 11 //失敗處理次數
Longest transaction: 29.04 //每次傳輸所花最長時間
Shortest transaction: 0.00 //每次傳輸所花最短時間
解壓: tar -zxvf siege-latest.tar.gz
cd siege-..*
./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/ssl
mkdir -p /usr/local/siege/etc
mkdir -p /usr/local/siege/var
make
make install

查看配置文件
/usr/local/siege/bin/siege -C

二、siege的使用
舉例說明:

50個用戶(每次並發量)重復100次 共產生 50*100 個請求
/usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com

50個用戶 重復100次 發送GET參數
/usr/local/siege/bin/siege -c 50 -r 100  http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=60

50個用戶 重復100次 發送POST參數 (註意引號)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST name=zhangsan"

50個用戶 重復100次 發送POST參數(從文件中讀取)
/usr/local/siege/bin/siege -c 50 -r 100  "https://www.abc.com/a.php POST < /root/ab_test/post.xml"

另外還有挺多參數
詳情請man 或 siege -h

siege報表解析,請man查看,暫略(有點累了,不想寫了。。。。。)。
Transactions:                     10 hits    :服務器接收的請求數
Availability:                 100.00 %       :有效情況的比例
Elapsed time:                   1.06 secs    :  測試所用的時間
Data transferred:               0.04 MB    :每個模擬用戶的數據傳輸量
Response time:                  0.03 secs    :響應每個模擬用戶請求的平均時間
Transaction rate:               9.43 trans/sec    :服務器每秒處理事務的平均數
Throughput:                     0.04 MB/sec    :服務器每秒跟所有模擬用戶的數據傳輸量
Concurrency:                    0.25    :每秒的模擬連接
Successful transactions:          10    :處理成功的事務數(code<400)
Failed transactions:               0    : 處理失敗的事務數(code>400)
Longest transaction:            0.04    :最長的事務處理時間
Shortest transaction:           0.02    :最短的事務處理時間

siege -c 200 -r 10 -f example.url
-c是並發量,-r是重復次數。 url文件就是一個文本,每行都是一個url,它會從裏面隨機訪問的。

example.url內容:

http://www.licess.cn
http://www.vpser.net
http://soft.vpser.net

結果說明
Lifting the server siege… done.
Transactions: 3419263 hits //完成419263次處理
Availability: 100.00 % //100.00 % 成功率
Elapsed time: 5999.69 secs //總共用時
Data transferred: 84273.91 MB //共數據傳輸84273.91 MB
Response time: 0.37 secs //相應用時1.65秒:顯示網絡連接的速度
Transaction rate: 569.91 trans/sec //均每秒完成 569.91 次處理:表示服務器後
Throughput: 14.05 MB/sec //平均每秒傳送數據
Concurrency: 213.42 //實際最高並發數
Successful transactions: 2564081 //成功處理次數
Failed transactions: 11 //失敗處理次數
Longest transaction: 29.04 //每次傳輸所花最長時間
Shortest transaction: 0.00 //每次傳輸所花最短時間

linux系統裏模擬並發請求siege