Welcome! Log In Create A New Profile

Advanced

Re: php-cgi constantly recycles every couple of minutes

merlin corey
January 28, 2010 04:54PM
On Thu, Jan 28, 2010 at 8:16 AM, mindfrost82 <nginx-forum@nginx.us> wrote:
> merlin corey Wrote:
> -------------------------------------------------------
>> On Mon, Jan 25, 2010 at 11:17 AM, mindfrost82
>> wrote:
>> > I run a fairly busy site with a Wordpress blog
>> and vBulletin forums.  I recently dumped Apache
>> and and using nginx for everything (which has been
>> incredible and I would never go back).  I'm using
>> PHP as fastCGI and have a wrapper script to start
>> the process.  We average about 1,000 concurrent
>> users at any given time.  Usually anywhere from
>> 800 to 1200+.
>> >
>> > This is the script I found to start php-cgi:
>> >
>> >
>> > #!/bin/sh
>> >
>> > PHP=/usr/bin/php-cgi
>> > PHP_PID=/tmp/php.pid
>> > FCGI_BIND_ADDRESS=127.0.0.1:8888
>> > PHP_FCGI_CHILDREN=4
>> > PHP_FCGI_MAX_REQUESTS=1000
>> >
>> > env -i PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN \
>> >
>>  PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS \
>> >       $PHP -b $FCGI_BIND_ADDRESS &
>> >
>> > echo $! > "$PHP_PID"
>> >
>> >
>> > This has been working great and PHP hasn't
>> completely died on me yet.
>> >
>> > The problem that I'm having is that while
>> viewing TOP, php-cgi seems to die and restart
>> about every 2-3 minutes, sometimes as often as
>> every minute.  At least it restarts itself, but
>> that can take a couple of seconds, causing a delay
>> if you happen to be browsing the site during this
>> time.
>> >
>> > In the above script, I've tried increasing the
>> PHP_FCGI_MAX_REQUESTS, even as high as 1,000,000.
>>  I've also tried completely omitting that value.
>>  No matter what, php-cgi reacts the same way.
>> >
>> > I know it needs to recycle itself to prevent
>> memory leaks, but I don't think it should be
>> happening that often.  Any ideas on how to fix
>> this?
>> >
>> > Posted at Nginx Forum:
>> http://forum.nginx.org/read.php?2,45516,45516#msg-
>> 45516
>> >
>> >
>> > _______________________________________________
>> > nginx mailing list
>> > nginx@nginx.org
>> > http://nginx.org/mailman/listinfo/nginx
>> >
>>
>> PHP_FCGI_MAX_REQUESTS=1000
>>
>> The children get automatically recycled when using
>> this method, I believe.
>>
>> -- Merlin
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://nginx.org/mailman/listinfo/nginx
>
> I'm not using php-fpm and don't really want to recompile PHP to switch to it. This is the only issue I have with this setup, so any help is appreciated. I tried taking out the PHP_FCGI_MAX_REQUESTS option altogether and it still recycled itself.  I also upped it to 1,000,000 and it didn't make a difference.
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,45516,46426#msg-46426
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx
>

What I was saying was that this is the expected behavior, from what I
can tell. Even with FPM children will still be getting started, but
you won't ever (in theory) run out of children as can sometimes happen
when php-cgi totally crashes.

You should try tuning for more children, 4 is nothing on such a busy
site. Try say 16 (or maybe more) children with 4096 max requests and
see if this improves things at all. If not you'll need to
horizontally scale out to more fastcgi servers for nginx to talk to.

-- Merlin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

php-cgi constantly recycles every couple of minutes

mindfrost82 January 25, 2010 02:17PM

Re: php-cgi constantly recycles every couple of minutes

Juan Fco. Giordana January 25, 2010 09:02PM

Re: php-cgi constantly recycles every couple of minutes

mike January 25, 2010 09:10PM

Re: php-cgi constantly recycles every couple of minutes

merlin corey January 26, 2010 06:00PM

Re: php-cgi constantly recycles every couple of minutes

mindfrost82 January 27, 2010 05:38PM

Re: php-cgi constantly recycles every couple of minutes

merlin corey January 28, 2010 04:54PM

Re: php-cgi constantly recycles every couple of minutes

Rob Schultz January 28, 2010 09:32PM

Re: php-cgi constantly recycles every couple of minutes

mindfrost82 January 29, 2010 09:38AM

Re: php-cgi constantly recycles every couple of minutes

Rob Schultz January 29, 2010 11:58AM

Re: php-cgi constantly recycles every couple of minutes

mindfrost82 January 29, 2010 12:04PM

Re: php-cgi constantly recycles every couple of minutes

merlin corey January 29, 2010 02:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 69
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready