apache ab 测试 apr_socket_connect,: 由于目标机器积极拒绝 无法连接

遇到这种情况一般是你开的并行数量太多了。。。例如:ab -c 1000 -n 10000 http://localhost/index.html 如此大的请求就会挂掉,不过还是有补救措施的,可以通过增加并发数上限解决这个问题,步骤如下:

1、停止Apache服务;

2、找到apache/conf/httpd.conf文件,用文本编辑器打开找到这两行:

# Server-pool management (MPM specific)

# Include conf/extra/httpd-mpm.conf

把第二行include........这行的注释去掉。

3、找到apache/conf/extra/httpd-mpm.conf文件,打开,找到:

<IfModule mpm_winnt_module>

ThreadsPerChild 150

MaxRequestsPerChild 0

</IfModule>

把上面的150调大,Windows下最大为1920.

注意:尖括号里的名字是winnt,不要看错了

4、重新启动Apache服务.