Linux学习14-ab报错apr_pollset_poll: The timeout specified has expired (70007)
前言
使用ab压力测试时候出现报错apr_pollset_poll: The timeout specified has expired (70007),本篇总结了几个ab常见的报错和对应解决办法
当并发数过大的时候,也会出现apr_socket_recv: Connection reset by peer (104)
apr_pollset_poll
如果出现apr_pollset_poll: The timeout specified has expired (70007),主要是timeout连接超时了,可以加个-k参数,让连接KeepAlive
ab -c 10 -n 5000 http://47.104.x.x:8082/
[root@yoyo sbin]# ab -c 10 -n 5000 http://47.104.x.x:8082/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 47.104.190.48 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
apr_pollset_poll: The timeout specified has expired (70007)
出现原因主要是timeout连接超时了,可以加个-k参数,让连接keep-alive,另外还有-r 和-s参数也可以加上
-r Don't exit on socket receive errors. # 在遇到socket接收错误后,不退出测试
-s timeout Seconds to max. wait for each response # 最大超时时间,默认30s
Default is 30 seconds
-k Use HTTP KeepAlive feature # keep-alive保持连接
加上-k参数重新运行就不会有问题了
ab -c 10 -n 5000 -k http://47.104.x.x:81/
其它异常
当并发数设置为1000时,直接报错:apr_socket_recv: Connection reset by peer (104)
[root@yoyo sbin]# ab -c 1000 -n 10000 http://47.104.x.x:81/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 47.104.190.48 (be patient)
apr_socket_recv: Connection reset by peer (104)
Total of 1 requests completed
当ab遇到严重的网络错误后,就会退出测试,因为这种错误说明网络存在其他问题,但是只要服务器返回数据,哪怕是数据不对,ab也会继续下去,但是会记录数据长度不对。
但事实上是:在高压力下,偶尔的一两个请求被阻止,这是一个正常的情况,特别是有防火墙或入侵检测系统的情况下,这种事情会经常发生。
那么ab有没有参数来跳过这种错误,使测试继续下去呢?
-r参数可以实现忽略这种错误,在遇到socket接收错误后,不退出测试
ab -c 10 -n 5000 -r http://47.104.x.x:81/
加上-r参数就不会遇到这种异常,中途退出了
交流QQ群:779429633