一个小型的商城单实例在跑,用户数量上来以后发现加载缓慢,检查阿里云发现80%的connection都not_established, 优化一下Apache配置试试。
先查看Apache的MPM工作模式
$ apachectl -V
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
Server's Module Magic Number: 20120211:24
Server loaded: APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
先改一个1000试试
<IfModule mpm_prefork_module>
StartServers 10
MinSpareServers 10
MaxSpareServers 50
ServerLimit 1000
MaxRequestWorkers 1000
MaxConnectionsPerChild 0
</IfModule>