AB post请求测试

ab post请求测试

1
ab -c 200 -n 1000 -T 'application/x-www-form-urlencoded' -p postdata.txt http://domain/test.php

以前不知道的你,很震惊

postdata.txt的内容类似如下

1
third=1&third_params={"uid":"12345","openid":"12345","name":"12345","gender":"0","iconurl":"12345"}&idfa=12345&device_imei12345&app_client_version=2.3.2.0&platform=android

这里注意下-c和-n的参数,两个参数的值是成倍数关系的,如果这样设置

1
ab -c 2 -n 4 -T 'application/x-www-form-urlencoded' -p postdata.txt http://domain/test.php

会提示参数错误

类似如下

1
ab: wrong number of arguments

-n和-c参数说明

1
2
3
-n:在测试会话中所执行的请求个数。默认时,仅执行一个请求。

-c:一次产生的请求个数。默认是一次一个。