安裝ab工具
yum install httpd-tools
參數說明
-n:執行的請求個數,默認時執行一個請求
-c:一次產生的請求個數,即並發個數
-p:模擬post請求,文件格式為gid=2&status=1,配合-T使用
-T:post數據所使用的Content-Type頭信息,如果-T 'application/x-www-form-urlencoded'
1.模擬get請求
直接在url后面帶參數即可
ab -c 10 -n 10 http://www.test.api.com/?gid=2
2.模擬post請求
在當前目錄下創建一個文件post.txt
編輯文件post.txt寫入
cid=4&status=1
相當於post傳遞cid,status參數
ab -n 100 -c 10 -p 'post.txt' -T 'application/x-www-form-urlencoded' 'http://test.api.com/ttk/auth/info/'