apache bench(ab)壓力測(cè)試模擬POSt請(qǐng)求
ab命令格式:
-N|--count 總請(qǐng)求數(shù),缺省 : 5w
-C|--clients 并發(fā)數(shù), 缺省 : 100
-R|--rounds 測(cè)試次數(shù), 缺省 : 10 次
-S|-sleeptime 間隔時(shí)間, 缺省 : 10 秒
-I|--min 最小并發(fā)數(shù), 缺省: 0
-X|--max 最大并發(fā)數(shù),缺省: 0
-J|--step 次遞增并發(fā)數(shù)
-R|--runtime 總體運(yùn)行時(shí)間,設(shè)置此項(xiàng)時(shí)最大請(qǐng)求數(shù)為5w
-P|--postfile post數(shù)據(jù)文件路徑
-U|--url 測(cè)試地址
要使用ab進(jìn)行post數(shù)據(jù)測(cè)試.從help可以看出我們需要定義兩個(gè)內(nèi)容
一個(gè)是-p參數(shù).指定需要post的數(shù)據(jù)
還有一個(gè)是-T參數(shù),指定使用的content-type
eg : ab -n 3 -c 3 -p post.txt -T application/x-www-form-urlencoded http://192.168.1.176:8080/xx.do
另外,post.txt里面的post數(shù)據(jù)要放你的json數(shù)據(jù),比如data={"id":"1234"}但是注意要進(jìn)行urlencode加密,于是真正放在post.txt里面的內(nèi)容就是data=%7B%22id%22%3A%221234%22%7D,還有要注意,不要自己在windows上建一個(gè)post.txt放數(shù)據(jù),而是使用比如eclipse或者notepad++,因?yàn)樽约航ㄒ粋€(gè)txt會(huì)在文件開頭有一個(gè)特殊字符,這樣解析不了。我是用的intellij idea開發(fā),用它建的txt文件。搞好之后你再ab以下肯定可以了。。。。
-p選項(xiàng)指定post文件的位置;-T選項(xiàng)指定post文件的編碼方式,默認(rèn)是明文,如果指定-T 'application/x-www-form-urlencoded',則表示post文件使用urlencode
注:content-type一定要設(shè)置成為application/x-www-form-urlencoded
技術(shù)改變世界!
--狂詩絕劍

浙公網(wǎng)安備 33010602011771號(hào)