I'm using FastCGI (fcgi). I'm having a problem where more PHP processes are being spawned than what should be, which is eating up my RAM.
I'm using WHM, and so have set the following PHP settings via WHM web interface > Apache Configuration > Include Editor > Pre VirtualHost Include:
<IfModule mod_fcgid.c> FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 500 FcgidMaxRequestsPerProcess 500 FcgidMaxProcesses 15 FcgidMinProcessesPerClass 0 FcgidMaxProcessesPerClass 8 FcgidIdleTimeout 30 FcgidIdleScanInterval 15 FcgidProcessLifeTime 60 FcgidIOTimeout 300 FcgidMaxRequestLen 268435456 </IfModule>
(Usually these settings would go in
/usr/local/apache/conf/php.conf, but this file is overwritten by WHM when changing various settings, so I had to insert them elsewhere. The above method was recommended in a cPanel forum, and causes the settings to be included in the Apache configuration.)
FcgidMaxProcesses 15, I've found via
top that up to 45 PHP processes are running at any given time during peak usage (and maybe more). For example, here is a screen shot taken last weekend:
I really want it limited to 15 processes, maximum. (Even though it looks like I have RAM to spare, it's really 2GB + 1GB burstable. I need to keep it under 2GB as a general rule.)
It's an Apache server, running CentOS 6, Apache 2 (Worker MPM), PHP 5.3.20 (FastCGI/fcgi), and MySQL 5.5.28. 2 GB RAM (3 GB burstable), 24 CPUs.