首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >服务器达到pm.max_children设置(280),请考虑提高它

服务器达到pm.max_children设置(280),请考虑提高它
EN

Server Fault用户
提问于 2017-08-03 07:47:26
回答 2查看 8.8K关注 0票数 4

由于到达pm.max_children,每隔几天PHP进程就会崩溃,我必须手动启动它来创建站点。

服务器配置:

代码语言:javascript
复制
Total Memory: 7986M 
CPU: 2 Core
1 PHP Process Taking: 22M

PHP配置:

代码语言:javascript
复制
pm = dynamic
pm.max_children = 280
pm.start_servers = 15
pm.min_spare_servers = 15
pm.max_spare_servers = 35
pm.max_requests = 1000

检查PHP日志,发现以下错误。

代码语言:javascript
复制
[02-Aug-2017 23:23:54] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 10 idle, and 41 total children
[02-Aug-2017 23:24:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 55 total children
[02-Aug-2017 23:24:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 63 total children
[02-Aug-2017 23:24:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 78 total children
[02-Aug-2017 23:24:07] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 93 total children
[02-Aug-2017 23:24:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 108 total children
[02-Aug-2017 23:24:09] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 123 total children
[02-Aug-2017 23:24:10] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 138 total children
[02-Aug-2017 23:24:11] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 153 total children
[02-Aug-2017 23:24:12] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 168 total children
[02-Aug-2017 23:24:13] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 183 total children
[02-Aug-2017 23:24:14] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 198 total children
[02-Aug-2017 23:24:15] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 213 total children
[02-Aug-2017 23:24:16] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 228 total children
[02-Aug-2017 23:24:17] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 243 total children
[02-Aug-2017 23:24:18] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 258 total children
[02-Aug-2017 23:24:19] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 273 total children
[02-Aug-2017 23:24:20] WARNING: [pool www] server reached pm.max_children setting (280), consider raising it

我可以有人建议为PHP的最佳优化配置,这可以帮助避免崩溃。

以下这句话的意思是:

代码语言:javascript
复制
[02-Aug-2017 23:23:54] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 10 idle, and 41 total children
EN

回答 2

Server Fault用户

发布于 2017-08-03 12:47:35

这里有一个计算正确数字的建议:

https://myshell.co.uk/blog/2012/07/adjusting-child-processes-for-php-fpm-nginx/

以下命令将帮助我们确定每个子进程(PHP)所使用的内存:

代码语言:javascript
复制
ps -ylC php-fpm --sort:rss

然后,获取服务器可用的RAM并计算:

代码语言:javascript
复制
pm.max_children = Total RAM dedicated to the web server / Max child process size

另见:

php5-fpm:服务器到达pm.max_孩子们

票数 2
EN

Server Fault用户

发布于 2017-08-03 20:00:20

首先,你应该找出你真正需要多少个fpm孩子。在池配置中启用慢速日志,或者使用外部服务(如NewRelic )查找代码中的慢点和弱点。可能是MySQL连接或PHP中存在瓶颈。你得到了“似乎很忙”,因为他们正忙着等待来自DataBase或其他方面的答复。无缘无故地增加pm.max_children是一种糟糕的做法。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/866616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档