Req #55166 [Com]: Implement a global limit to the overall number of php processes
Edit report at https://bugs.php.net/bug.php?id=55166&edit=1
ID: 55166
Comment by: albertcasademont at gmail dot com
Reported by: trollofdarkness at gmail dot com
Summary: Implement a global limit to the overall number of
php processes
Status: Analyzed
Type: Feature/Change Request
Package: FPM related
PHP Version: 5.3SVN-2011-07-09 (SVN)
Assigned To: fat
Block user comment: N
Private report: N
New Comment:
This is an amazing feature guys, thank you very much! Any news on backporting the patch to 5.3?
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2011-07-17 17:22:33] trollofdarkness at gmail dot com
Ok :) Thank you for your reactivity ;)
------------------------------------------------------------------------
[2011-07-17 07:43:22] fat@php.net
Commited into 5.4. Thx you very much for your help.
I'll wait 5.3.7 is out before backporting this to 5.3 branch.
------------------------------------------------------------------------
[2011-07-17 07:41:53] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&revision=313323
Log: - Implemented FR #55166 (Added process.max to control the number of process FPM can fork)
------------------------------------------------------------------------
[2011-07-09 12:07:18] trollofdarkness at gmail dot com
Description:
------------
Hi everyone,
I post here a patch that adds the ability to php-fpm to globally limit the global number of php
processes.
I made it for personal purpose as I have an "only" 2GB RAM server and several website
running on it.
The problem is the following, when you have several pools :
* Either you choose to have a max_children which is low, you won't go out of memory, but if
there is a peak on a specific website while the other ones are quiet, this specific website will be
slow, because there will be a queue for the FastCGI requests
* Or you choose to have a max_children which is high and you thus allow peaks on your websites, but
if ever there is a peak on several website at the same time, chances are that your server will go
out of memory.
With this patch, I introduce a new configuration directive :
[global]
max_total_processes = 40
40 will be the total number of php processes authorized to be launched in memory at the same time.
When trying to fork a new process (only in the case on pm = dynamic (or pm = ondemand, by the way))
the FPM will look at the current total number of processes that are launched in memory. This is made
easy to integrate because FPM already has a fpm_globals.running_children variable referencing the
total number of children, all pools summed up. I just had to add a condition, a variable & the
ability to read a new config option. SO this is a really, really small patch ! But very useful I
think.
The current uploaded patch file has been made for the PHP 5.3 SVN Branch source. Feel free to adapt
it to another version of the sources if you want, you will see that it is just a matter of 4-5
changes in the source code.
Hope it will be useful.
-- Troll
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55166&edit=1
Thread (8 messages)