limiting the number of php-cgi processes starting

3 posts / 0 new
Last post
#1 Mon, 12/08/2014 - 11:12
edwardsmarkf

limiting the number of php-cgi processes starting

hello all -

I have about eight /usr/sbin/httpd processes running. each will start up multiple /usr/bin/php-cgi processes. (note that i am using "CGI wrapper" not fast-cgi)

what is the best way to limit the number of /usr/bin/php-cgi processes that can start up?

i did try playing with the following values but wanted to get some expert opinions first:

<IfModule prefork.c> 
StartServers       8 
MinSpareServers    5 
MaxSpareServers   20 
ServerLimit      256 
MaxClients       40     ## changed from 256 
MaxRequestsPerChild  4000 
</IfModule> 
 
<IfModule worker.c> 
StartServers         4 
MaxClients         40    ## changed from 256 
MinSpareThreads     25 
MaxSpareThreads     75 
ThreadsPerChild     25 
MaxRequestsPerChild  0 
</IfModule>
Mon, 12/08/2014 - 12:07
andreychek

Howdy,

What you're changing is exactly right. It sounds like your server may have too many active connections as once, and limiting MaxClients is a good way to prevent your server's resources from being overwhelmed.

The only issue though is that if you're frequently at that limit -- it would also prevent legitimate connections as well. In that case, you may wish to review your site's logs, and determine what IP's are accessing your site, and what they're up to.

You could be seeing certain bots that are hammering away at your site that could be blocked. Or perhaps there are certain areas of your site that are experiencing a problem that could be corrected (ie, a plugin that's taking a long time to respond).

-Eric

Mon, 12/08/2014 - 13:48
edwardsmarkf

hey eric - as always, THANK YOU for your extraordinarily patience with me. i am ready to nominate you for sainthood.

i just cranked the number down from 40 to 30 to see if that helps. i have been previously sweeping through memory using something like a

ps -ef | grep php-cgi ;

every couple of seconds and if the number gets too high, i kill those processes. not an optimium solution! i also scour the log files every five minutes or so and if i see too much activity i block 'em.

and speaking of blocking them, i notice that our friends at csf have added a

--tempdeny

command so our deny files dont fill up.

but ideally, i would not have so much server overhead trying to deal with my server getting hammered. it only seems to happen during the AM hours when i am getting my beauty sleep.

Topic locked