Web性能壓力測試工具Siege怎么用,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
10年積累的網(wǎng)站制作、成都做網(wǎng)站經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先做網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有繁峙免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Siege是一款開源的壓力測試工具,設(shè)計用于評估WEB應(yīng)用在壓力下的承受能力。可以根據(jù)配置對一個WEB站點進行多用戶的并發(fā)訪問,記錄每個用戶所有請求過程的相應(yīng)時間,并在一定數(shù)量的并發(fā)訪問下重復(fù)進行。
Siege可以從您選擇的預(yù)置列表中請求隨機的URL。所以siege可用于仿真用戶請求負載,而ab則不能。但不要使用siege來執(zhí)行***性能基準調(diào)校測試,這方面ab就準確很多。
Siege官網(wǎng):http://www.joedog.org/
一、安裝
編譯安裝
wget http://www.joedog.org/pub/siege/siege-latest.tar.gz tar -zxvf siege-latest.tar.gz cd siege-2.72/ ./configure make make install
通過包安裝
Debian/Ubuntu
apt-get install siege
CentOS
yum install siege
二、參數(shù)詳解
命令行參數(shù)說明:
-C,或–config 在屏幕上打印顯示出當前的配置,配置是包括在他的配置文件HOME/.siegerc
-f FILE, –file=FILE 指定用特定的urls文件運行siege ,默認為urls.txt,位于siege 安裝目錄下的etc/urls.txt
-u URL,–url=URL 測試指定的一個URL,對它進行”siege “,此選項會忽略有關(guān)urls文件的設(shè)定
-b 進行壓力測試,不進行延時。
-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)到達這個數(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
三、用法舉例
siege -c 300 -r 100 -f url.txt
說明:-c是并發(fā)量,-r是重復(fù)次數(shù)。url.txt就是一個文本文件,里面是要測試的url,url.txt每行都是一個url。
urls.txt文件是很多行待測試URL的列表以換行符斷開,格式為:
[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é)果說明:
** SIEGE 2.72 ** Preparing 10 concurrent users for battle. The server is now under siege.. done. Transactions: 300 hits #已完成的事務(wù)總署 Availability: 100.00 % #完成的成功率 Elapsed time: 0.08 secs #總共使用的時間 Data transferred: 0.94 MB #響應(yīng)中數(shù)據(jù)的總大小 Response time: 0.00 secs #顯示網(wǎng)絡(luò)連接的速度 Transaction rate: 3750.00 trans/sec #平均每秒完成的事務(wù)數(shù) Throughput: 11.79 MB/sec #平均每秒傳送的數(shù)據(jù)量 Concurrency: 8.50 #實際***并發(fā)鏈接數(shù) Successful transactions: 300 #成功處理的次數(shù) Failed transactions: 0 #失敗處理的次數(shù) Longest transaction: 0.01 #最長事務(wù)處理的時間 Shortest transaction: 0.00 #最短事務(wù)處理時間
四、常用的siege命令舉例
200個并發(fā)對www.google.com發(fā)送請求100次
siege -c 200 -r 100 http://www.google.com
在urls.txt中列出所有的網(wǎng)址
siege -c 200 -r 100 -f urls.txt
隨機選取urls.txt中列出所有的網(wǎng)址
siege -c 200 -r 100 -f urls.txt -i
delay=0,更準確的壓力測試,而不是功能測試
siege -c 200 -r 100 -f urls.txt -i -b
指定http請求頭 文檔類型
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中含有空格和中文,要先進行url編碼,否則siege發(fā)送的請求url不準確
siege自身感覺也是有瓶頸的,并發(fā)數(shù)***也就1000,再提高就會報下面這樣的錯誤
[error] socket: unable to connect sock.c:222: Operation already in progress socket: connection timed out
這樣最終導致測試結(jié)果怎么都沒法超過2W每秒的請求,所以就把siege -c 1000 -r 100 -i -b -f url.txt 放到shell中并發(fā)執(zhí)行
#!/bin/bash user_agent="Siege 1.0" siege_rc="siege.rc" concurrent=150 repet=200 siege_single_urls="singleurl.txt" siege_prefix_urls="prefixurl.txt" for i in {1..10} do siege -c $concurrent -r $repet -i -b -f $siege_single_urls -R $siege_rc -A "$user_agent" &; done
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。
文章標題:Web性能壓力測試工具Siege怎么用
本文地址:http://www.chinadenli.net/article44/jdjcee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護、品牌網(wǎng)站制作、關(guān)鍵詞優(yōu)化、動態(tài)網(wǎng)站、網(wǎng)站策劃、小程序開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)