Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.)

However, despite 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:

screenshot of top output

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.

share|improve this question
1  
Ever have any luck on this? –  ylluminate Dec 31 '13 at 10:22
    
I eventually moved to a server with a lot more RAM, so the PHP processes ceased to be an issue. –  Michael Jan 2 at 16:53

1 Answer 1

I believe the following may be the right approach to addressing this in cPanel: http://www.ray.45press.com/configure-mpm-apache-xcache-fcgid-in-cpanel/

In particular it has to do with editing /usr/local/cpanel/cgi-sys/php5 to include the following lines:

export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10000

But be sure that PHP_FCGI_MAX_REQUESTS matches the FcgidMaxRequestsPerProcess from the Apache config.

Further you want to pay attention to the note in the file of copying this over to the appropriate location (/var/cpanel/conf/apache/wrappers/php5) so that it is retained upon apache or php updates.

share|improve this answer
    
I have "export PHP_FCGI_CHILDREN=0" as per instructions under "Special PHP considerations" at httpd.apache.org/mod_fcgid/mod/mod_fcgid.html. Also my PHP_FCGI_MAX_REQUESTS=1000. –  Michael Jan 2 at 16:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.