apache 的连接限制配置

apache 的连接限制配置

今天测试遇到一个问题,apache 对新的连接一直没有响应,而旧的连接还能工作。

查看 apache 错误日志,有一个日志记录:

 AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting

一直没有留意过 apache 的连接配置,看错误的信息,应该是连接数超过了 apache 的某个配置。

查一下 apache 的连接情况

lsof -i -n -P | grep apache2

看结果很多连接了。于是,查了一下,找到了 apache 的 MPM 工作模式的介绍 http://blog.csdn.net/STFPHP/article/details/52954303
修改加大了 prefork 的连接限制:

<IfModule mpm_prefork_module>
    StartServers            10
    MinSpareServers         5
    MaxSpareServers         20
    MaxRequestWorkers       100
    MaxConnectionsPerChild  10000
</IfModule>

其中 MaxConnectionsPerChild 为进程处理了多少了连接之后进行回收,有助力于减少内存泄漏。

除了 prefork 模式,apache 还支持 worker 和 event 模式。 worker 模式混合使用了进程和线程,event 则更进一步(event is based on the worker MPM)。
在event 模式下,连接只在活跃时才分配 worker 来处理,其底层采用的是 apache 封装过的非阻塞式 IO。

posted @ 2018-03-13 14:36  drop *  阅读(210)  评论(0编辑  收藏  举报