这是一个关于选择正确的 Apache httpd MPM的规范问题。
我对 Apache 提供的不同 MPM 有点困惑——'worker'、'event'、'prefork' 等。
它们之间的主要区别是什么,我如何确定哪一个最适合给定的部署?
我有一台 128 GB Ram 的机器,它使用 Apache2 作为 Web 服务器(在这台机器上没有数据库服务器,数据库机器是一台 64 GB Ram 机器,可以处理 2000 个最大连接)。我使用监控工具看到目前大约有 44 个忙碌的工作人员和 12 个空闲的工作人员,我的 prefork 模块的最佳理论值是多少?
我有时会在高负载时间加载网站时出现空白页面,并在我的 apache 错误日志中出现此错误:
【注意】child pid 13595 exit signal Segmentation fault (11)
如何解决这个问题呢?
我的 Apache2 Prefork 模块配置:
StartServers 3
MinSpareServers 3
MaxSpareServers 5
ServerLimit 3200
MaxClients 3100
MaxRequestsPerChild 0
Run Code Online (Sandbox Code Playgroud)
在 www 机器上免费 -h:
总计:128 G 空闲空间:97GB(运行 apache2)共享 0b 缓冲区 1.9G 缓存 23G
Apache2 和其他程序使用的 Ram:
Private + Shared = RAM used Program
96.0 KiB + 61.0 KiB = 157.0 …
Run Code Online (Sandbox Code Playgroud) hosting mpm-prefork shared-hosting segmentation-fault apache-2.2
我正在运行 CentOS 64 位,刚刚发现我在我的双四核 Xeon 上运行 prefork MPM。有人告诉我,worker 会给我更低的内存使用率和更高的性能,因为我运行的是一个流量非常高的网站。
如果这是真的,我该怎么做?
目前在 Ubuntu 14.04 上的 Apache 2(确切地说是 Apache 2.4.7)上,我有以下设置:
/etc/apache2/mods-enabled/mpm_prefork.conf
<IfModule mpm_prefork_module>
StartServers 20
MinSpareServers 100
MaxSpareServers 250
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
Run Code Online (Sandbox Code Playgroud)
该服务器是一个 8GB (RAM) 的亚马逊服务器,它只会为一些谷歌广告活动加载一个三页的注册表单。
我在网上找到了一个名为apachetuneit.sh的脚本,但是过了一会儿,Apache 报告了这个错误:
[Tue Apr 21 16:45:42.227935 2015] [mpm_prefork:error] [pid 1134] AH00161:服务器达到 MaxRequestWorkers 设置,考虑提高 MaxRequestWorkers 设置
如何判断如何设置这些设置?
我只是专门询问如何调整 Apache 2.4 而没有其他问题。这就是为什么这个问题与这个问题不同。
ubuntu performance-tuning mpm-prefork apache-2.4 ubuntu-14.04
I'm running a relatively low-traffic site that experiences a large spike in visitors once a week following a site update. During this spike, site performance is extremely poor compared to the rest of the week. The actually load on the servers remains very low, reliably under 10% CPU and under 30% RAM (the hardware should be complete overkill for what we're actually doing), but for some reason Apache seems to be unable to cope with the quantity of requests. We …
我目前有一个 Apache2 服务器,mpm-prefork
它mod_php
在 OpenVZ VPS 上运行,具有 512M 真实/1024M 可爆内存(无交换)。运行一些测试后,我发现 Apache 获得的最大进程大小是 23M,所以我设置MaxClients
为 25(23M x 25 = 575 MB,对我来说还可以)。我决定在我的服务器上运行一些负载测试,结果让我感到困惑。
我ab
在我的台式机上使用从 wordpress 博客请求主页。
当我运行ab
24 个并发连接时,一切似乎都很好。当然,CPU 上升,空闲 RAM 下降,结果是每个请求的响应时间约为 2-3 秒。
但是如果我运行ab
25 个并发连接(我的服务器限制),Apache 会在几秒钟后挂起。它开始处理请求,然后停止响应,CPU 回到 100% 空闲并ab
超时。Apache 日志说它已达到MaxClients
.
发生这种情况时,Apache 将自己锁定在 25 个正在运行的进程中(如果我检查服务器状态,它们都处于“W”状态)并且只有在TimeOut
设置后进程开始死亡并且服务器再次开始响应(在我的情况下它已设置到 45)。
我的问题:这是预期的行为吗?为什么 Apache 到达时就死了MaxClients
?如果它适用于 24 个连接,它不应该适用于 25 个连接,只是花更多的时间来响应每个请求并将其余的排队?
对我来说,任何一个正在运行的孩子ab
都可以通过设置与服务器的并发连接来单独杀死一个网络服务器,这对我来说有点奇怪MaxClients
。
我正在尝试优化我们的 Web 服务器以处理尽可能多的连接。我阅读了很多帖子和 Apache 笔记。我试图了解我应该为 选择哪个值MaxRequestsPerChild
。
起初,我尝试将其设置为 4,000,但服务器在处理许多请求时遇到困难,因此我开始提高它。目前我的设置是:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 40000
</IfModule>
Run Code Online (Sandbox Code Playgroud)
将 设置MaxRequestsPerChild
为 40,000 后,服务器设法在不使用更多内存/CPU 的情况下处理更多连接。
谁能告诉我这个值是太高了还是可以有这么高的值?
谢谢!
操作系统信息:
[root@web06 ~]# uname -a
Linux web 2.6.18-164.el5PAE #1 SMP Thu Sep 3 04:10:44 EDT 2009 i686 i686 i386 GNU/Linux
[root@web06 ~]# free
total used free shared buffers cached
Mem: 3814660 3502968 311692 0 144368 2970468
-/+ buffers/cache: 388132 3426528
Swap: 5210104 0 5210104
Run Code Online (Sandbox Code Playgroud) 我有一个运行在带有 CentOS 的 AWS 微型实例上的Apache 2.4网络服务器。
apache 正在运行带有 prefork MPM 模块的 PHP。
服务器通过 Amazon 负载均衡器访问,该负载均衡器具有健康检查功能,每 60 秒尝试访问服务器的 index.php 网页。
问题是在 1-2 天后,Apache 以某种方式使用 index.php 页面达到了 256 个打开的进程并给出以下错误:
[Sun Sep 08 02:13:00.356051 2013] [mpm_prefork:error] [pid 1201] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
[Sun Sep 08 02:13:13.656694 2013] [mpm_prefork:error] [pid 1201] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
Run Code Online (Sandbox Code Playgroud)
通常发生这种情况时,不再接受新的 http 连接。
Apache 可能不会关闭负载均衡器的所有连接。
我们有另一台使用 Apache 2.2 的服务器,它没有这个问题,所以问题可能出在 2.4 版本上,它与 2.2 有很大不同(我们没有更改 Apache 的任何默认配置)。 …
我有这个设置:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 1250
MaxClients 1250
MaxRequestsPerChild 1500
</IfModule>
Run Code Online (Sandbox Code Playgroud)
当我做 top 时,是否有 5-10 个最小/最大服务器设置,有大量的 apache 2 进程?
他们不应该只在5-10之间吗?看看 260 进程休眠 O_O (d*mn apache)
点击http://img200.imageshack.us/img200/3285/senzatitolo1iw.jpg
编辑1:
在 30 分钟后,顶部屏幕显示:
点击:http : //img816.imageshack.us/img816/1645/immagineov.png
UP 24 小时后(使用 MEM 的最高订购者)
感谢您的任何解释
(debian 6,灯,4GB 内存)
mpm-prefork ×10
apache-2.2 ×8
linux ×3
mpm-worker ×3
apache-2.4 ×2
centos ×1
hosting ×1
httpd ×1
openvz ×1
optimization ×1
performance ×1
php ×1
settings ×1
timeout ×1
ubuntu ×1
ubuntu-14.04 ×1