【发布时间】:2018-03-22 16:43:20
【问题描述】:
我们在 16GB AWS 实例上,我发现它真的很慢。我跑的时候
ps -aux | grep apache
我可以看到大约 60 多个 apache 进程。
我跑的时候
watch -n 1 "echo -n 'Apache Processes: ' && ps -C apache2 --no-headers | wc -l && free -m"
它显示了 apache 使用的几乎所有内存。
我跑的时候
curl -L https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl
要查看如何优化 Apache,它建议我增加 MaxRequestWorkers 的数量,因此我将其设置为 550。我还将 MaxConnectionsPerChild 从 0(无限制)更改为 10000。
这是我的 /etc/apache2/mods-enabled/mpm_prefork.conf 文件
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 550
MaxConnectionsPerChild 10000
</IfModule>
你能告诉我我们如何优化 apache 内存使用,这样它就不会导致整个网站瘫痪吗?
【问题讨论】:
标签: apache out-of-memory ubuntu-14.04