Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is my current php5-fpm configuration

listen =
listen.allowed_clients =
user = www-data
group = www-data
pm = dynamic
pm.max_children = 50
pm.start_servers = 25
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 2500
pm.status_path = /php-status
slowlog = log/$pool.log.slow
chdir = /
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

I am more dev than ops, so please assume I am quite ignorant about Linux and general server admin knowledge.

My linux box is a

Ubuntu 12.10 (Quantal Quetzal)  1024 MB RAM, 40 GB Disk from Rackspace.

My purpose is to use it for a single website running on cakephp 2.3

Right now, I am running Jenkins on the same server to help with continuous deployment for the application code on the server.

Once we have enough traffic, I intend to move the Jenkins into a separate server.

At this point in time, I have yet to install Jenkins, but I have already installed Php5-fpm and Nginx. The memory usage has gone from 4% to 41% after installing php5-fpm.

I have yet to move my application code to this server and yet to install Jenkins on the server.

My questions are:

  1. how do I read this php5-fpm configuration i have setup, starting from pm to pm.status_path? now this is a standalone question over here.
  2. what are the implications if i change some of the settings, especially pm.max_children?
  3. how do i optimize the settings for my setup, considering that I intend to install jenkins as well as running a website? What if I run two websites?
share|improve this question

closed as not a real question by mgorven, Michael Hampton, Ward, mdpc, Tom O'Connor Dec 26 '12 at 12:27

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer

  1. Uh... look at the manual? http://php-fpm.org/wiki/Configuration_File

  2. Even if you set your max children too high, if your server can serve the requests without any issues while keeping a low load, nothing happens. Because you'll never reach max children. But if your children is too high and you do get more requests than you can handle, php-fpm will hog all the memory and start crashing and possibly even lock up the system. Though, it's lot less painful than apache hogging all the ram (apache in such is like worse than a virus...). So, if request / second > servable / second, your max children will be reached and you want that state to be still stable.

  3. You cannot optimize without actual traffic data (or simulated load). You can guess, but it's not really important. I can guess that your max children, start servers, min spare servers is too high (it probably is), but without real traffic, I could be wrong or it could be irrelevant. Additionally, it's a VPS, it's hard to even say an optimal exists (aside from highly non-optimal) because the environment can change at any time without any of your input. For example, another user could be added to the node and uses large amount of resource affecting you and all optimization you did till now becomes meaningless. That's not an oddity, but common since the resources in a VPS fluctuates more by not-you than you.

Here are some general tips on optimization.

  • If the usage of ram is too high, or poses a risk of going into swap (swap is too slow!), you should decrease max children. So, if 1 child takes 5% of ram, you don't want more than 20 children as that would consume all the ram and more. Though, should note, avg is not max. Higher the maximum, higher users you can serve simultaneously.
  • If you have memory leak in your software or software handler (ie php), decrease max requests so that the children is recreated quickly. You're really just trying avoiding wasting time of creating new processes by having a high number. I personally suggest away from any higher than 10K just in case php-fpm itself has any memory leak.
  • If you want more steady behavior (cpu optimize), set a high min/max spare servers
  • If you want more dynamic behavior (ram optimize), set a low min/max spare servers
share|improve this answer
If the usage of ram is too high (what is considered as too high?) while i understand that if 1 child takes 5% ram, i don't want more than 20, what would be the acceptable range for ram used by the children in total? –  Kim Stacks Dec 26 '12 at 7:53
It would depend. Enough ram so that ALL the application can fit in ram. Simplest way of knowing if you're using too much ram is if you're using swap. Swap is just too darn slow to be realistically usable in an active php environment. You also want some amount of free ram for OS buffer/caches. But as you're on VPS, that depends on more details of your vps virtualizer. –  Grumpy Dec 26 '12 at 9:58
I have 1 situation where the memory usage is 46% but the swap usage is 26%. is that considered bad? and what details of the vps do I need to give? –  Kim Stacks Dec 26 '12 at 13:53
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.