From:             
Operating system: 
PHP version:      5.3SVN-2011-07-09 (SVN)
Package:          FPM related
Bug Type:         Feature/Change Request
Bug description:Implement a global limit to the overall number of php processes

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 bug report at https://bugs.php.net/bug.php?id=55166&edit=1
-- 
Try a snapshot (PHP 5.2):            
https://bugs.php.net/fix.php?id=55166&r=trysnapshot52
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55166&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55166&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55166&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55166&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55166&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55166&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55166&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55166&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55166&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55166&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55166&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55166&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55166&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55166&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55166&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55166&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55166&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55166&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55166&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55166&r=mysqlcfg
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55166&r=trysnapshot54

Reply via email to