首先我們的json字符串直接放在文件postfile中
在我們使用json格式時,注意一定要將headers的Content_type設置爲application/json,否則服務器端可能不能正確識別傳送的body格式。
siege
經過測試的版本爲3.02和3.04
siege POST請求:
嘗試1:
siege -T 'application/json' -c 500 r 1 '10.23.54.151:19595/v1/db/nova/service_get_all POST <./postfile'
服務器端接收到body爲postfile文件內容,但是content_type依舊是默認值“application/x-www-form-urlencoded”,致使服務器端不能正確處理。
嘗試2:
siege -H 'Content-Type:application/json' -c 500 r 1 '10.23.54.151:19595/v1/db/nova/service_get_all POST <./postfile'
情況與1相同。說明不能通過-H和-T來修改content_type
嘗試3:
將postfile文件名修改爲postfile.json
siege -c 500 r 1 '10.23.54.151:19595/v1/db/nova/service_get_all POST <./postfile.json'
content_type被正確設置爲application/json,服務器正常處理返回。原來siege只能通過文件的擴展名來確定content type格式
此處參考http://www.joedog.org/siege-faq/
ad
該工具比較好用,沒出現什麼問題,一條命令搞定:
ab -n 5000 -c 500 -p postfile -T 'application/json' '10.23.54.151:19595/v1/db/nova/service_get_all'
測試搞定