2

Sorry, I am new and deleted my question thinking I had posted some info I should not have. I am posting the edited question once again:

In our website, php5-fpm takes care of the php calls made by the browser We have received a lot of outages/504s lately. Now, I checked the php5-fpm logs to correlate with the timestamps of 504 in - our access logs and this is what I got in the php5-fpm logs:

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

Please observe that the php5-fpm was not able to handle the connections since it has a current limit of pm.max_children setting set only to 5 (Please see below) and is way too less based on our workload:

unknown@xxxx:~# cat /etc/php5/fpm/pool.d/www.conf | grep "pm.max_children =" pm.max_children = 5

My question is, how do I calculate the new value? I have 4 GB of RAM and the DB is running on a diff server.

1

To find out the correct value, we need to find the average memory being used by one php-fpm process.

Active php-fpm processes memory consumption: root@example:~# ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | grep php-fpm

  • 111.50 Mb php-fpm: pool www
  • 55.60 Mb php-fpm: pool www
  • 52.25 Mb php-fpm: pool www
  • 12.45 Mb php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
  • 0.31 Mb grep php-fpm
  • Now, for your specific case:
  • Average memory consumption per process: (111.50+55.60+52.25)/3 = 73.12 Mb
  • Total available memory = 4000 Mb and since DB is running of a separate server, it would be safe to consume 3000 Mb of memory.
  • So, the new numbers of pm.max_children based on the above calculation = 3000/74 = 40.54 ~ 40
  • Upon setting the correct value, you should not see pm.max_children error/warning in your php-fpm logs.
  • Thanks a lot! I do not see the error messages after changing the value. – Dadda Jan 2 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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