php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54098 Overly high defaults in config
Submitted: 2011-02-25 05:56 UTC Modified: 2011-10-08 20:01 UTC
From: marco at mimecom dot net Assigned: fat
Status: Closed Package: FPM related
PHP Version: trunk-SVN-2011-02-25 (SVN) OS: Linux
Private report: No CVE-ID:
 [2011-02-25 05:56 UTC] marco at mimecom dot net
Description:
------------
The default setting in the pool sets pm.max_children to 50, which with php's 
upped default memory_limit of 128Mb makes many moderately equipped machines to 
crash from out-of-memory.  The settings combined makes it possible to consume 
6GB of memory in a bad scenario. Since I suspect many a server nowadays are 1Gb 
(or even 512Mb) VPS's running on the different clouds out there, the settings 
are grossly excessive. I reported a bug against Ubuntu at first, but I think 
this is really the right place for it. 

https://bugs.launchpad.net/ubuntu/+source/php5/+bug/723480

pm.max_children should be more like 6 initially, with an explanation to increase 
the number if memory permits. Ether that or the default memory_limit should be 
lowered.

I have read posts about running VPS where operators have to reboot every so 
often, and I think it *might* have to do with this problem, since I'm sure 
nginx+php+php-fpm is getting very popular as a stack. 


Expected result:
----------------
Snappy happy server.

Actual result:
--------------
Server get sad, wrinkles, get dementia, finally get a stroke and dies. Takes as 
long time as it took my mother but in computer-years. 

Patches

php-fpm.conf.in.diff (last revision 2011-02-25 04:57 UTC) by marco at mimecom dot net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-25 08:05 UTC] fat@php.net
-Status: Open +Status: Assigned -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: fat
 [2011-02-25 08:05 UTC] fat@php.net
It's not a bug it a feature ;)

The subject will be discussed with other dev soon. I'll keep you updated.

For me, default value, especialy those one should not be called "default value", 
but "exemple values". Saying that FPM is widely used in VPS with 512Mb of RAM is 
just a wrong assumption. As saying that FPM is widely used with physical servers 
with 12Gb of RAM. It depends on the server on which FPM runs but on the code 
itself. At the end, the sysadm is the only one who can set the right values.

So if 50 is too high for some, they will lower it to 6. For others 50 will be 
too low and they will higher it to 200 or whatever.

From my point of vue, 50 is maybe quite too high, but the proposed value are too 
low. If you really want to lower the max and still use the dynamic PM, we can 
set:
pm.max_children = 10
;pm.start_servers = 2
;pm.min_spare_servers = 1
;pm.max_spare_servers = 4
 [2011-02-25 08:25 UTC] marco at mimecom dot net
Well, since the configuration is active - not commented out - I'd say it is 
pretty much a default. A default make install would run with this configuration 
without modifications. You are right that my statement of there being a lot of 
1Gb servers out there is taken out of the air - but I run a few (and two with 
512Mb - still snappy), I know they are cheap (and it gets pretty expensive when 
you try to run larger servers) so it's just my *suspicion* that they are common.   
In any case, since the settings effectively are a default per above, I'd much 
rather see the software underperform than bring servers down. One way to fix it 
would be to comment out that setting and not let php-fpm start unless you go 
configuring yourself. But do mention in that comment to crosscheck with php's 
memory setting. It took a giant jump from a default 16M to 128M, which is why I 
think these settings kill servers. Before, at 16M, 50 was actually great.

P.S. I don't really know what prompted that jump above, but it's not my 
concern...  I guess there were reasons for it.
 [2011-02-25 08:37 UTC] marco at mimecom dot net
Further arguing the low memory systems a bit: I commonly get myself a 512M slice 
to start development of a site. It's fast enough to develop on - and when time 
come to deploy, I'd ramp it up to something faster. So the low memory scenario 
is highly valid in my case. And even if we are not talking clouds, I think many 
places in the world would have low-memory hardware due to cost reasons. In the 
cloud, slices commonly start at 256M even - although even I feel it's too low.

Compare to MySQL - a default install is tuned for the lowest common denominator 
as well, making sure it runs. The nice dining of large systems comes with a 
tuning dessert...
 [2011-07-02 13:54 UTC] fat@php.net
See http://news.php.net/php.internals/53723 for updates
 [2011-07-05 17:03 UTC] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&revision=312957
Log: - Implemented FR #54098 (Lowered default value for Process Manager)
 [2011-07-05 17:05 UTC] fat@php.net
-Status: Assigned +Status: Closed
 [2011-07-05 17:05 UTC] fat@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I didn't make my point on this :)

patch have been applied and will default values for 5.4 and trunk.
 [2011-07-05 17:06 UTC] fat@php.net
it'll be backport to 5.3 when 5.3.7 will be released
 [2011-07-05 17:06 UTC] fat@php.net
-Status: Closed +Status: Analyzed
 [2011-07-05 20:27 UTC] marco at mimecom dot net
Glad it got resolved in my favor (sorry..) -- Whenever I get the cash to run those 
big memory systems I'll definitely know where to increase the limits. I do some 
sysadmin stuff and rely on sane defaults. I just don't have the time to go in and 
tinker on every single part of my systems, so having something crash slowly on me 
just because I hadn't given it my full attention was just not a good situation...
 [2011-10-08 13:38 UTC] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&revision=317893
Log: - Backported FR #54098 from 5.4 branch (Lowered process manager default value)
 [2011-10-08 20:01 UTC] fat@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2011-10-08 20:01 UTC] fat@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 08:02:33 2014 UTC