PHP-FPM pm.max_children设置依据
2016-12-31 13:15
281 查看
原文:http://myshell.co.uk/blog/2012/07/adjusting-child-processes-for-php-fpm-nginx/
Problem:
The following warning message appears in the logs:[26-Jul-2012 09:49:59] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 8 idle, and 58 total children [26-Jul-2012 09:50:00] WARNING: [pool www] server reached pm.max_children setting (50), consider raising it
It means that there are not enough PHP-FPM processes.
Solution:
We need to calculate and change these values based on the amount of memory on the system:/etc/php-fpm.d/www.conf
pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35
- the following command will help us to determine the memory used by each (PHP-FPM) child process:
ps -ylC php-fpm --sort:rss
The RSS column shows non-swapped physical memory usage by PHP-FPM processes in kilo Bytes.
On an average each PHP-FPM process took ~75MB of RAM on my machine.
Appropriate value for pm.max_children can be calculated as:
pm.max_children = Total RAM dedicated to the web server / Max child process size - in my case it was 85MB
The server has 8GB of RAM, so:
pm.max_children = 6144MB / 85MB = 72
I left some memory for the system to breath. You need to take into account any other services running on the machine while calculating memory usage.
I’ve changed the settings as follow:
pm.max_children = 70 pm.start_servers = 20 pm.min_spare_servers = 20 pm.max_spare_servers = 35 pm.max_requests = 500
Please note that very high values does not mean necessarily anything good.
You can check an average memory usage by single PHP-FPM process with this handy command:
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
You can use the same steps above to calculate the value for MaxClients for Apche web server - just substitute thephp-fpm with
httpd.
相关文章推荐
- nginx moodle php-fpm pm.max_children
- 通过php-fpm status判断pm.max_childern的值应该设置为多少
- php-fpm优化方法 pm.max_children、pm.min_spare_servers、pm.max_spare_servers
- PHP-FPM的pm.max_children 配置值怎么计算?
- php-fpm优化方法 pm.min_spare_servers、pm.max_spare_servers 的真实意义
- 深入理解php-fpm.conf中的两个重要参数---max_children和request_timeout
- 深入理解php-fpm.conf中的max_children和request_terminate_timeout
- 深入理解php-fpm.conf中的两个重要参数---max_children和request_timeout
- lnmp压力测试结果php处理能力低,增加pm.max_children后一样没提升
- PHP-PHP-FPM的max_children一些误区
- php-fpm.conf重要参数max_children和request_terminate_timeout
- php-fpm.conf 重要参数 max_children 和 request_terminate_timeout
- 我是做商城的,一天有20万PV,服务器是R420 双CPU 内存是16G怎么配置参数呀?php-fpm.conf max_children 和 max_requests怎么配置 还有nginx.con
- PHP-FPM日志中出现”好像很忙碌”,您需要增加pm.start_servers,或pm.min/ max_spare_servers
- php-fpm优化方法 pm.min_spare_servers、pm.max_spare_servers 的真实意义
- php-fpm.conf 重要参数 max_children 和 request_terminate_timeout(转)
- nginx php上传大文件的设置(php-fpm)
- 阿里云CentOS6.5(nginx+PHP-fpm)及RDS初级使用指南和简单安全设置