web-dev-qa-db-ja.com

サーバーがpm.max_children設定(280)に達しました。上げることを検討してください

PHP-FPMプロセスがpm.max_childrenに到達のために数日ごとにクラッシュするため、サイトを構成するために手動で起動する必要があります。

サーバー構成:

Total Memory: 7986M 
CPU: 2 Core
1 PHP Process Taking: 22M

PHP-FPM設定:

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-FPMログを確認すると、次のエラーが見つかりました。

[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-FPMに最適な構成を提案できます。これは、クラッシュを回避するのに役立ちます。

以下の行はどういう意味ですか:

[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
2
Irk

正しい数を計算するための1つの提案を次に示します。

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

次のコマンドは、各(PHP-FPM)子プロセスで使用されているメモリを判別するのに役立ちます。

ps -ylC php-fpm --sort:rss

次に、サーバーの使用可能なRAMを取得し、以下を計算します。

pm.max_children = Total RAM dedicated to the web server / Max child process size

参照:

php5-fpm:サーバーがpm.max_childrenに到達しました

2
JayMcTee

まず最初に、本当に必要なfpmの子の数を調べます。プール構成でスローログを有効にするか、NewRelicなどの外部サービスを使用して、コード内のスロースポットとウィークスポットを見つけます。 MySQL接続またはPHPカールにボトルネックがある可能性があります。データベースなどからの応答を待つのに忙しいため、「忙しそう」になりました。理由なくpm.max_childrenを増やすことは悪い習慣です。

0