大网数据广告活动
网站运营与故障问答

server reached pm.max_children setting (5)

· 52CE 我爱测

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 …

问题原文

原帖链接 · Dadda · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · st_rt_dl_8 · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-01-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。