Apache-2.2

Apache 伺服器上的最大連接數限製配置 - CentOS 6.4

  • August 16, 2016

我們有一個 Apache 和一個 CherryPy (Python) 伺服器在 CentOs 6.4 上執行。昨天 Apache 伺服器突然宕機,而使用埠 8080 的 CherryPy 工作正常。我們正在嘗試解決問題,但沒有運氣。似乎最大同時連接數有問題,但我們不知道如何解決這個問題,甚至不知道真正的問題。錯誤日誌文件是這樣的:

   [Sun Aug 04 04:47:16 2013] [notice] mod_python: Creating 4 session mutexes based on 10       max processes and 0 max threads.
   [Mon Aug 05 21:57:31 2013] [notice] mod_python: Creating 4 session mutexes based on 10   max processes and 0 max threads.
   [Mon Aug 05 21:58:46 2013] [error] server reached MaxClients setting, consider raising the MaxClients setting  

有誰知道如何解決這個問題?

PS我們完全是伺服器的新手。

您應該檢查 /etc/httpd/conf/httpd.conf 中的值

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

您應該更改您正在使用的處理模型(可能是工人)

您可以嘗試從 top/atop/htop 的輸出中確定有多少客戶端可以為您服務

# top
top - 15:06:24 up 41 days, 16:18,  2 users,  load average: 3.58, 2.59, 2.34
Tasks: 204 total,   1 running, 203 sleeping,   0 stopped,   0 zombie
Cpu(s): 14.6%us,  0.5%sy,  0.0%ni, 84.3%id,  0.3%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:  24676512k total, 14828220k used,  9848292k free,   343688k buffers
Swap:  2102456k total,      188k used,  2102268k free, 10690524k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
19965 apache    16   0  413m 113m 3980 S  5.7  0.5   3:11.01 httpd
20954 apache    16   0  383m  83m 3952 S  5.7  0.3   1:16.31 httpd
21274 apache    16   0  382m  81m 3988 S  5.7  0.3   0:29.20 httpd
21376 apache    16   0  371m  67m 3728 S  5.7  0.3   0:03.58 httpd
20943 apache    16   0  384m  83m 3948 S  5.3  0.3   1:18.98 httpd
20969 apache    16   0  384m  83m 3928 S  5.3  0.3   1:18.67 httpd
21264 apache    16   0  382m  80m 3796 S  5.3  0.3   0:27.93 httpd
21364 apache    16   0  379m  75m 3848 S  5.3  0.3   0:04.28 httpd
21370 apache    16   0  378m  75m 3712 S  5.3  0.3   0:04.31 httpd
21371 apache    16   0  378m  74m 3772 S  5.3  0.3   0:04.51 httpd
21374 apache    16   0  379m  74m 3804 S  5.3  0.3   0:03.50 httpd
21377 apache    16   0  379m  76m 3896 S  5.3  0.3   0:04.54 httpd
21043 apache    16   0  383m  82m 3976 S  5.0  0.3   1:17.40 httpd
21262 apache    16   0  382m  81m 3900 S  5.0  0.3   0:28.30 httpd

從輸出中可以看出 - 一個 apache 程序(RES 列)所需的平均 RAM 量約為 80 mb

引用自:https://serverfault.com/questions/528973