问题原文
原帖链接 · 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 www55.60 Mb php-fpm: pool www52.25 Mb php-fpm: pool www12.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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
