ab 發送post請求測試API性能

apache benchmark 工具 測試API 性能發送 Post 請求(Linux環境驗證通過

在apache bin 目錄,在linux上執行命令:
./ab -n 1 -v 4 -p 'userlogin.txt' -T 'application/x-www-form-urlencoded' 'http://api.xxxxx.com/1/login'

說明:
(1)
 userlogin.txt 這裏邊記錄是API的post請求的參數,放在和ab相同目錄下(/opt/app/apache-2.4.12/bin),內容如下,
user_name=639493678400&password=A1111111&cheers=1
(2)  這個api只需要2個參數user_name,password,如果 參數文件中寫成 user_name=639493678400&password=A1111111的話,還是報錯,所以又多傳了個參數cheers=1,這樣就不報錯了(和開發溝通下,說是佔位符的問題),這點非常重要。  

最後說明:在windows系統中,使用ab還是會報錯,所以大家注意,這個篇文章是針對Linux系統的。

---------------------------------------------------- 被測試API -----------------------------------------------------

Login
Login with username and password credential.
URLhttp://api.xxxxx.com/1/login
Request Method: POST
Request
Header


FieldRequiredDescription
User-AgentOUser Agent of Client
X-User-AgentMExtend User Agent of Client

Body

FieldRequiredDescription
user_nameMName of user
passwordMPassword of user credential
deviceOLogin device id
pwd_flagO1:encrypted 0:non-encrypted(default)









Body

FieldData TypeDescription
tokenstringAccess token for business interaction.
expires_inlongValid time range of access token. (Seconds)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章