WARNING: server reached pm.max_children setting.

The other day, while I was checking the php5-fpm.log file on one of my Nginx web servers, I came across the following warning:

WARNING: [pool www] server reached pm.max_children setting (5), consider raising it.

Unfortunately, many of the help articles out there fail to do a great job of explaining where this particular setting is located or how you should go about changing it. Instead, most of them talk about the pm.max_children directive as if the reader automatically knows how to modify it.

Note that my setup is as follows:

  • Ubuntu 12.10
  • Nginx as a web server.
  • PHP FPM.
  • This is written from the perspective of somebody who uses one FPM pool (as is evident from the error, I am using the default www pool).

On Ubuntu, the pm.max_children setting can be found in a file called /etc/php5/fpm/pool.d/www.conf

In that file, you will find a technical explanation of the setting:

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.

In this particular scenario, the pm.max_children setting was set to 5. After changing it (I upped it to 15), I made sure to restart PHP FPM by using the following command:

sudo /etc/init.d/php5-fpm restart

Over the next week or so, I’ll keep an eye on the logs. Remember: You should make sure that you understand these settings before you start increasing them. It is also a good idea to benchmark the results of any change that you make to your performance settings!