2

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 http://f.cl.ly/items/1H2M452J1K2p0Z231H2y/Screen%20Shot%202013-01-19%20at%207.16.44%20AM-2.png

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.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
Michael
  • 81
  • 1
  • 9
  • 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 02 '14 at 16:53
  • [Administration panels are off topic](http://serverfault.com/help/on-topic). [Even the presence of an administration panel on a system,](http://meta.serverfault.com/q/6538/118258) because they [take over the systems in strange and non-standard ways, making it difficult or even impossible for actual system administrators to manage the servers normally](http://meta.serverfault.com/a/3924/118258), and tend to indicate low-quality questions from *users* with insufficient knowledge for this site. – HopelessN00b Mar 11 '15 at 20:06

1 Answers1

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.

ylluminate
  • 1,155
  • 2
  • 17
  • 35
  • I have "export PHP_FCGI_CHILDREN=0" as per instructions under "Special PHP considerations" at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html. Also my PHP_FCGI_MAX_REQUESTS=1000. – Michael Jan 02 '14 at 16:59