apache bench(ab)壓力測試類比POSt請求

來源:互聯網
上載者:User

標籤:code   font   sleep   編碼   count   地址   格式   已耗用時間   txt   

ab命令格式:-N|--count 總請求數,預設 : 5w-C|--clients 並發數, 預設 : 100-R|--rounds 測試次數, 預設 : 10 次-S|-sleeptime 間隔時間, 預設 : 10 秒-I|--min 最小並發數, 預設: 0-X|--max 最大並發數,預設: 0-J|--step 次遞增並發數-R|--runtime 總體已耗用時間,設定此項時最大請求數為5w-P|--postfile post資料檔案路徑-U|--url 測試地址

 

要使用ab進行post資料測試.從help可以看出我們需要定義兩個內容
一個是-p參數.指定需要post的資料
還有一個是-T參數,指定使用的content-type

eg :

ab -n 3 -c 3 -p post.txt -T application/x-www-form-urlencoded http://192.168.1.176:8080/xxab -n 1 -c 1 -p post.txt -T application/octet-stream  http://172.25.33.211:8088/dsp/rtb

  

另外,post.txt裡面的post資料要放你的json資料,比如

data={"id":"1234"}

但是注意要進行urlencode加密,於是真正放在post.txt裡面的內容就是data=%7B%22id%22%3A%221234%22%7D,還有要注意,不要自己在windows上建一個post.txt放資料,而是使用比如eclipse或者notepad++,因為自己建一個txt會在檔案開頭有一個特殊字元,這樣解析不了。我是用的intellij idea開發,用它建的txt檔案。搞好之後你再ab以下肯定可以了。。。。

 

-p選項指定post檔案的位置;-T選項指定post檔案的編碼方式,預設是明文,如果指定-T ‘application/x-www-form-urlencoded‘,則表示post檔案使用urlencode           

apache bench(ab)壓力測試類比POSt請求

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.