1. 程式人生 > >ab壓力測試之post與get請求

ab壓力測試之post與get請求

安裝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/'