Dynamically Start/Stop FastCGI PHP Processes

Edho Arief edho at myconan.net
Thu Mar 15 03:37:58 UTC 2012

Am 15.03.2012 10:30 schrieb "justin" <nginx-forum at nginx.us>:
> Ok, so I've got a crazy idea, but it might just work.
> Basically, we have a bunch of PHP pools managed with PHP-FPM. Each site
> has its own single PHP-FPM worker for security reasons.
> The majority of the sites don't get much traffic, so the PHP processes
> don't need to be running eating up RAM and resources. My thought was
> after N number of minutes of no requests to shut down that PHP worker
> for that site. Then when a request comes in, hold the request in sort-of
> a pause mode, start the worker for that site, and then forward off the
> request. Sure there would be a slight delay on that first request to
> spin up the worker, but should work beautifully.
> Does nginx have any plugins to emulate this behavior? I.E. sort of
> hooks? All I would need is a hook from nginx when a site is idle for X
> number of second/minutes. For this first hook, we could write a simple
> bash script which kills that PHP-FPM worker. Then another hook, when a
> request comes in on a given site. Again, another bash script which first
> checks if the PHP-FPM worker is up, if not, holds the requests, starts
> the worker, and then forwards the request.
> I was thinking at first, I can use node.js and write a middleware proxy
> that sits between nginx and the PHP-FPM workers, but then quickly
> realized the node.js app would have to speak cgi, and I didn't want to
> have to deal with that rubbish. :)

What you're looking for is php-fpm with 0 initial worker. I'm not sure how
far its current progress but you should try asking php folks. In the
meantime you can config the pool to start with only one inital worker.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120315/8038695d/attachment.html>

More information about the nginx mailing list