0%

ab

安装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/