ab 傳送post請求 測試API效能
阿新 • • 發佈:2019-01-01
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)
最後說明:在windows系統中,使用ab還是會報錯,所以大家注意,這個篇文章是針對Linux系統的。
---------------------------------------------------- 被測試API -----------------------------------------------------
Login
Login with username and password credential.
URL: http://api.xxxxx.com/1/login
Request Method:
POST
Request
Header
Field | Required | Description |
---|---|---|
User-Agent | O | User Agent of Client |
X-User-Agent | M | Extend User Agent of Client |
Field | Required | Description |
---|---|---|
user_name | M | Name of user |
password | M | Password of user credential |
device | O | Login device id |
pwd_flag | O | 1:encrypted 0:non-encrypted(default) |
Body
Field | Data Type | Description |
---|---|---|
token | string | Access token for business interaction. |
expires_in | long | Valid time range of access token. (Seconds) |