php-fastcgi and memory leaks

Phillip B Oldham phill at theactivitypeople.co.uk
Tue Mar 25 12:44:14 MSK 2008


Further to the email below, I'm still having problems with PHP5 fastcgi 
and nginx. I'm finding that php slowly takes up 100% of the available 
memory and starts to drop connections at around 70%. At the moment I've 
got monit restarting the fastcgi processes when the memory usage hits 
70%, but this isn't optimal as the scripts I'm running shouldn't take 
anywhere near that on a virtual server with 300MB dedicated ram.

I'm wondering whether anyone else has come across the same problem 
running php5 fastcgi who has managed to find a fix or work-around?

> I was seeing something similar with PHP5 fastcgi and lighttpd, though 
> it was a lot more than 10% - maybe 25-50. I'm getting a little worried 
> as I think I may be seeing the same thing at around 5-10% with nginx.
>
> During my investigations into why this was happening in lighttpd, I 
> came across the following paragraph in the mod_fcgi docs:
>> Adds a MaxRequestsPerProcess parameter that allows mod_fcgid to exit 
>> after handling a certain number of requests, similar to the existing 
>> ProcessLifeTime option.
>>
>> This solves a problem with PHP in FastCGI mode. By default, PHP stops 
>> accepting new FastCGI connections after handling 500 requests; 
>> unfortunately, there is a potential race condition during the PHP 
>> cleanup code in which PHP can be shutting down but still have the 
>> socket open, so mod_fcgid under heavy load can send request number 
>> 501 to PHP and have it "accepted", but then PHP appears to simply 
>> exit, causing errors.
> Not too sure if your rails app/mongrel is restarting processes after a 
> set limit and coming across the same race condition?
>
> If this problem is could become aparent in nginx it would be great if 
> there was a plugin to spawn and manage fcgi threads which could limit 
> the number of connections to each backend.
>
> HTH.
> Phill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phill.vcf
Type: text/x-vcard
Size: 261 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20080325/a55ba4c4/attachment.vcf>


More information about the nginx mailing list