ab命令格式:
-N|--count 总请求数,缺省 : 5w
-C|--clients 并发数, 缺省 : 100
-R|--rounds 测试次数, 缺省 : 10 次
-S|-sleeptime 间隔时间, 缺省 : 10 秒
-I|--min 最小并发数, 缺省: 0
-X|--max 最大并发数,缺省: 0
-J|--step 次递增并发数
-R|--runtime 总体运行时间,设置此项时最大请求数为5w
-P|--postfile post数据文件路径
-U|--url 测试地址
要使用ab进行post数据测试.从help可以看出我们需要定义两个内容
一个是-p参数.指定需要post的数据
还有一个是-T参数,指定使用的content-type
eg :
ab -n 3 -c 3 -p post.txt -T application/x-www-form-urlencoded http://192.168.1.176:8080/xx
ab -n 1 -c 1 -p post.txt -T application/octet-stream http://172.25.33.211:8088/dsp/rtb
另外,post.txt里面的post数据要放你的json数据,比如
data={"id":"1234"}
但是注意要进行urlencode加密,于是真正放在post.txt里面的内容就是data=%7B%22id%22%3A%221234%22%7D,还有要注意,不要自己在windows上建一个post.txt放数据,而是使用比如eclipse或者notepad++ÿ