apache 的鏈接限制配置

apache 的鏈接限制配置

今天測試遇到一個問題,apache 對新的鏈接一直沒有響應,而舊的鏈接還能工做。apache

查看 apache 錯誤日誌,有一個日誌記錄:ide

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

一直沒有留意過 apache 的鏈接配置,看錯誤的信息,應該是鏈接數超過了 apache 的某個配置。測試

查一下 apache 的鏈接狀況.net

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。code

相關文章
相關標籤/搜索