自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Web性能壓力測試工具——Siege詳解

運維 系統(tǒng)運維
Siege是一款開源的壓力測試工具,設(shè)計用于評估WEB應(yīng)用在壓力下的承受能力??梢愿鶕?jù)配置對一個WEB站點進(jìn)行多用戶的并發(fā)訪問,記錄每個用戶所有請求過程的相應(yīng)時間,并在一定數(shù)量的并發(fā)訪問下重復(fù)進(jìn)行。

[[171526]]

Siege是一款開源的壓力測試工具,設(shè)計用于評估WEB應(yīng)用在壓力下的承受能力。可以根據(jù)配置對一個WEB站點進(jìn)行多用戶的并發(fā)訪問,記錄每個用戶所有請求過程的相應(yīng)時間,并在一定數(shù)量的并發(fā)訪問下重復(fù)進(jìn)行。

Siege可以從您選擇的預(yù)置列表中請求隨機的URL。所以siege可用于仿真用戶請求負(fù)載,而ab則不能。但不要使用siege來執(zhí)行***性能基準(zhǔn)調(diào)校測試,這方面ab就準(zhǔn)確很多。

Siege官網(wǎng):http://www.joedog.org/

一、安裝

  • 編譯安裝
  1. wget http://www.joedog.org/pub/siege/siege-latest.tar.gz 
  2. tar -zxvf siege-latest.tar.gz 
  3. cd siege-2.72/ 
  4. ./configure 
  5. make 
  6. make install 
  • 通過包安裝

Debian/Ubuntu

  1. apt-get install siege 

CentOS

  1. yum install siege 

二、參數(shù)詳解

  • 命令行參數(shù)說明:

-C,或–config 在屏幕上打印顯示出當(dāng)前的配置,配置是包括在他的配置文件HOME/.siegerc

-f FILE, –file=FILE 指定用特定的urls文件運行siege ,默認(rèn)為urls.txt,位于siege 安裝目錄下的etc/urls.txt

-u URL,–url=URL 測試指定的一個URL,對它進(jìn)行”siege “,此選項會忽略有關(guān)urls文件的設(shè)定

-b 進(jìn)行壓力測試,不進(jìn)行延時。

-A, —user-agent=”text” 設(shè)置請求的User-Agent

  • siegerc設(shè)定檔說明:

verbose :要不要顯示過程。

display-id :顯示過程的時候,要不要顯示模擬user的id

show-logfile :跑完之后要不要顯示log資訊

logging :要不要log到檔案

logfile :要log到檔案的話,檔名是什么

protocol :HTTP通訊協(xié)定( HTTP/1.1或HTTP/1.0 兩者擇一)

connection :keep-alive表示模擬成persistent connection(寫close則反之)

concurrent :模擬有幾個user來沖

time :跑多久之后停止( H=hours, M=minutes, S=seconds)

reps :每一個concurrent沖幾次。

file :多個目的url情形下的url檔案位置。

url :單一url情形下的指定url

delay :非benchmakr行況下,每個模擬user隨機延遲0到這個數(shù)字(單位:秒)。

timeout :socket connection timeout(單位:秒)。

failures :socket失敗次數(shù)(timeouts, connection failures)到達(dá)這個數(shù)字就停下來。

internet :隨機從urls.txt抓出url,否則從urls.txt循序。

benchmark :跑benchmark模式的話,siege將不會在每個connection間delay,適合拿來做load testing.

user-agent :送出的agent識別

login :WWW-Authenticate login( login = jdfulmer:topsecret:Admin )(非form based)

username,password :也是login用的(非form based)

Login URL :每一個模擬user都必需經(jīng)過的***個login url( form based)

proxy-host,proxy-port,proxy-login :使用proxy的話要填這個。(proxy-login: jeff:secret:corporate)

follow-location :redirection support

zero-data-ok :接不接受zero-length data

chunked :HTTP/1.1需要chunked encoding

三、用法舉例

  1. siege -c 300 -r 100 -f url.txt 

說明:-c是并發(fā)量,-r是重復(fù)次數(shù)。url.txt就是一個文本文件,里面是要測試的url,url.txt每行都是一個url。

urls.txt文件是很多行待測試URL的列表以換行符斷開,格式為:

  1. [protocol://]host.domain.com[:port][path/to/file] 

url.txt內(nèi)容:

http://192.168.80.166/01.jpg

http://192.168.80.166/02.jpg

http://192.168.80.166/03.jpg

http://192.168.80.166/04.jpg

http://192.168.80.166/05.jpg

http://192.168.80.166/06.jpg

結(jié)果說明:

  1. ** SIEGE 2.72 
  2. ** Preparing 10 concurrent users for battle. 
  3. The server is now under siege..      done. 
  4.  
  5. Transactions:                 300 hits  #已完成的事務(wù)總署 
  6. Availability:              100.00 %   #完成的成功率 
  7. Elapsed time:                0.08 secs   #總共使用的時間 
  8. Data transferred:            0.94 MB   #響應(yīng)中數(shù)據(jù)的總大小 
  9. Response time:                0.00 secs   #顯示網(wǎng)絡(luò)連接的速度 
  10. Transaction rate:         3750.00 trans/sec  #平均每秒完成的事務(wù)數(shù) 
  11. Throughput:               11.79 MB/sec  #平均每秒傳送的數(shù)據(jù)量 
  12. Concurrency:                8.50  #實際***并發(fā)鏈接數(shù) 
  13. Successful transactions:         300  #成功處理的次數(shù) 
  14. Failed transactions:               0    #失敗處理的次數(shù) 
  15. Longest transaction:            0.01   #最長事務(wù)處理的時間 
  16. Shortest transaction:            0.00   #最短事務(wù)處理時間 

四、常用的siege命令舉例

  • 200個并發(fā)對www.google.com發(fā)送請求100次
  1. siege -c 200 -r 100 http://www.google.com 
  • 在urls.txt中列出所有的網(wǎng)址
  1. siege -c 200 -r 100 -f urls.txt 
  • 隨機選取urls.txt中列出所有的網(wǎng)址
  1. siege -c 200 -r 100 -f urls.txt -i 

delay=0,更準(zhǔn)確的壓力測試,而不是功能測試

  1. siege -c 200 -r 100 -f urls.txt -i -b 

指定http請求頭 文檔類型

  1. siege -H "Content-Type:application/json" -c 200 -r 100 -f urls.txt -i -b 

五、Siege使用的一些總結(jié)

  • 發(fā)送post請求時,url格式為:http://www.xxxx.com/ POST p1=v1&p2=v2
  • 如果url中含有空格和中文,要先進(jìn)行url編碼,否則siege發(fā)送的請求url不準(zhǔn)確
  • siege自身感覺也是有瓶頸的,并發(fā)數(shù)***也就1000,再提高就會報下面這樣的錯誤
  1. [error] socket: unable to connect sock.c:222: Operation already in progress socket: connection timed out 

這樣最終導(dǎo)致測試結(jié)果怎么都沒法超過2W每秒的請求,所以就把siege -c 1000 -r 100 -i -b -f url.txt 放到shell中并發(fā)執(zhí)行

  1. #!/bin/bash 
  2. user_agent="Siege 1.0" 
  3. siege_rc="siege.rc" 
  4. concurrent=150 
  5. repet=200 
  6. siege_single_urls="singleurl.txt" 
  7. siege_prefix_urls="prefixurl.txt" 
  8.  
  9. for i in {1..10} 
  10. do 
  11. siege -c $concurrent -r $repet -i -b -f $siege_single_urls -R $siege_rc -A "$user_agent" &; 
  12. done 

六、參考文檔

http://www.google.com

http://t.cn/Rt8w7Se

http://www.ha97.com/4663.html

http://longmu.blog.51cto.com/431337/943008

責(zé)任編輯:武曉燕 來源: 運維之美
相關(guān)推薦

2019-11-22 09:38:50

工具代碼開發(fā)

2015-07-14 09:11:11

Web服務(wù)器Siege

2015-07-27 18:19:22

Linuxstress參數(shù)

2010-06-04 16:07:09

Linux 性能測試工

2019-03-15 09:17:22

Web測試工具

2012-06-25 14:30:48

Web

2011-04-07 13:53:25

Web工具

2009-05-18 08:52:17

壓力測試Rpplet測試

2012-02-02 09:12:16

JavaJMeter

2010-06-07 17:46:46

Linux壓力測試工具

2013-05-17 10:37:43

.NETWEB壓力測試WEB壓力測試工具

2009-07-06 10:22:26

Web網(wǎng)站壓力測試

2012-08-01 10:50:48

性能測試測試架構(gòu)

2010-06-07 14:42:47

Linux性能測試工具

2010-05-17 13:16:23

MySQL壓力測試工具

2011-10-09 11:00:17

2012-02-09 09:35:46

NUnit

2025-01-26 11:05:23

2024-03-06 18:09:06

Linux性能工具

2010-05-27 18:48:20

Linux壓力測試工具
點贊
收藏

51CTO技術(shù)棧公眾號