PHP接口并发测试的方法
header('Content-type:text/html; Charset=utf-8');$uri = "输入你的url";
$data = array(
'test'=>1
);
$ch = curl_init();
// print_r($ch);
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$return = curl_exec($ch);
curl_close($ch);
然后用ab小工具测试
键入命令:
ab -n 800 -c 800 http://192.168.0.10/
(-n发出800个请求,-c模拟800并发,相当800人同时访问,后面是测试url 一般用本地测试就行了)
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/19041.html