nginx + php5-fpm server sometimes slow and gives 502 error

user1821484 asked:

I am running nginx + php5-fpm. My server usually is very fast but today I noticed that from time to time website “stucks” for 10-20 seconds. Not always, but sometimes it ends with 502 Bad Gateway error.

I investigated logfiles and founf the following:
1) (nging logfile) connect() failed (110: Connection timed out) while connecting to upstream
2) (php5-fpm logfile) [16-Feb-2013 01:20:53] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it.

It’s strange because today I have not much users online. Sometimes I have 2x more but everything works fine.
Does anyone know how to increase pm.max_children setting? I checked /etc/php5/fpm/php-fpm.conf file but there is nothing like “pm.max_children setting”.

My answer:


You’ll find pm.max_children in your pool configuration file in the /etc/php-fpm.d/ directory. The default file is www.conf which configures the first and default pool.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.