PHP-FCGI children don't get killed

Title says it all. The php5 child processes spawned by www-data don't get killed for a long time. They are not "orphan" (i.e they aren't owned by init) so killing them manually might cause some data loss.

I have PHPFCGIMAX_CHILDREN = 5 in my config. I've executed ab -n 1000 -c 5 [domain] in another machine while watching "top" on my linode.

 9828 www-data  20   0  105m  26m  14m S    0  7.7   0:20.02 php5                                                                                            
 9830 www-data  20   0  105m  26m  14m S    0  7.7   0:23.29 php5                                                                                            
 9829 www-data  20   0  105m  26m  14m S    0  7.6   0:39.03 php5                                                                                            
 9638 www-data  20   0  104m  26m  14m S    0  7.6   0:31.26 php5                                                                                            
 9690 www-data  20   0  103m  25m  14m S    0  7.2   0:31.88 php5  

As you can see, all of the children remain at ~7.7% RAM which, to me, is simply a waste of resources.

Is there a way to terminate the children immediately after their work is done?

7 Replies

The whole point of FastCGI is to keep the PHP processes alive so that you don't need to start a new process when another request comes along. Why would you want to kill them?

I have several domains hosted on my linode. For the high traffic ones, yes, that is what I want. But for low traffic ones I'd like the children to get destroyed immediately.

I have seperate config files for all domains, so each can have it's own fcgi settings.

So, is there any way to kill them immediately?

Why don't you use mod_php5 instead for those websites?

I guess that's possible, I've never used fcgi and mod_php at the same time. Do they play well together?

@dcelasun:

I guess that's possible, I've never used fcgi and mod_php at the same time. Do they play well together?

Yes, I've used them together and never had any problems.

Or use plain old CGI for simplicity's sake, if your sites are really low traffic. It works just like FastCGI except that the process(es) will exit after serving each request.

I have been reading some articles about apache2 + fcgid + php5 and there these 2 articles have diferente approaches:

http://2bits.com/articles/apache-fcgid- … ation.html">http://2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html

http://typo3.org/development/articles/u … 45a565e1de">http://typo3.org/development/articles/using-php-with-mod-fcgid/?txrlmpofficedocumentspi1%5Bview%5D=single&cHash=45a565e1de

I prefer 2bits version but none mention php opcodes like xcache.

Is there any problem using xcache with 2bits version?

I've read that we must be very carefully with fcgid and xcache to avoid ram wasting.

Another question is the configuration for:

ServerLimit

StartServers

MinSpareServers

MaxSpareServers

MaxClients

MaxRequestsPerChild

I'm running a 360 linode. What are your suggestions?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct