久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Web性能壓力測試工具Siege怎么用

176次閱讀
沒有評論

共計(jì) 3598 個(gè)字符,預(yù)計(jì)需要花費(fèi) 9 分鐘才能閱讀完成。

Web 性能壓力測試工具 Siege 怎么用,很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面丸趣 TV 小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

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

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

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, 或 ndash;config 在屏幕上打印顯示出當(dāng)前的配置, 配置是包括在他的配置文件 HOME/.siegerc

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

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

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

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

siegerc 設(shè)定檔說明:

verbose:要不要顯示過程。

display-id:顯示過程的時(shí)候,要不要顯示模擬 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:模擬有幾個(gè) user 來沖

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

reps:每一個(gè) concurrent 沖幾次。

file:多個(gè)目的 url 情形下的 url 檔案位置。

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

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

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

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

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

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

user-agent:送出的 agent 識(shí)別

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

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

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

proxy-host,proxy-port,proxy-login:使用 proxy 的話要填這個(gè)。(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 就是一個(gè)文本文件,里面是要測試的 url,url.txt 每行都是一個(gè) 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 #總共使用的時(shí)間  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 #實(shí)際 *** 并發(fā)鏈接數(shù)  Successful transactions: 300 #成功處理的次數(shù)  Failed transactions: 0 #失敗處理的次數(shù)  Longest transaction: 0.01 #最長事務(wù)處理的時(shí)間  Shortest transaction: 0.00 # 最短事務(wù)處理時(shí)間

四、常用的 siege 命令舉例

200 個(gè)并發(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

隨機(jī)選取 urls.txt 中列出所有的網(wǎng)址

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

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

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 請求時(shí),url 格式為:http://www.xxxx.com/ POST p1=v1 p2=v2

如果 url 中含有空格和中文,要先進(jìn)行 url 編碼,否則 siege 發(fā)送的請求 url 不準(zhǔn)確

siege 自身感覺也是有瓶頸的,并發(fā)數(shù) *** 也就 1000,再提高就會(huì)報(bào)下面這樣的錯(cuò)誤

[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í)行

#!/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)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注丸趣 TV 行業(yè)資訊頻道,感謝您對丸趣 TV 的支持。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-04發(fā)表,共計(jì)3598字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 平凉市| 桐柏县| 扶余县| 聂荣县| 平舆县| 清水河县| 宜宾市| 钟祥市| 常山县| 温州市| 平凉市| 柳林县| 当雄县| 宁津县| 澄城县| 江城| 公安县| 叙永县| 磐石市| 青田县| 乐业县| 女性| 长宁区| 建湖县| 广德县| 偏关县| 阜新市| 河津市| 景宁| 镇康县| 玉门市| 滕州市| 晋州市| 三河市| 两当县| 金乡县| 合山市| 天津市| 中牟县| 荣昌县| 谷城县|