PHP-FPM - you may need to increase pm.start_servers, or pm.min/max_spare_servers - Warningエラー対処法

当ページのリンクには広告が含まれています。

スポンサーリンク

nginx + php-fpm で運用しているサーバーが「you may need to increase pm.start_servers, or pm.min/max_spare_servers」というWarningエラーを吐いていたので、その対処方法を紹介します。

PHP-FPMの詳細はこちらを参考にしてください。
» PHP-FPMのインストールと設定

Warningエラーの詳細です。

# less /var/log/php-fpm/error.log | grep pm.start_servers
[28-Aug-2013 23:27:31] 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 14 total children
[29-Aug-2013 05:36:10] 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 10 total children
[29-Aug-2013 05:36:11] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 1 idle, and 12 total children
[29-Aug-2013 05:36: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 1 idle, and 13 total children
[29-Aug-2013 07:01:47] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 12 total children

「pm.start_servers、pm.min_spare_servers、pm.max_spare_servers を増やしたほうがいいかも」というWarningエラーが表示されています。

pm.start_servers とは

起動時に作成される子プロセスの数です。
pm = dynamic の場合 にのみ適用されます。

pm.min/max_spare_servers とは

アイドル状態時の子プロセスの最小/最大数です。
pm = dynamic の場合 にのみ適用されます。

エラー対処法

PHP-FPMの設定ファイル(/etc/php-fpm.d/www.conf)を編集し、「pm.start_servers」「pm.min/max_spare_servers」を増やします。以下の数値は、サーバーの状況に応じて変更しましょう。

pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 70

編集前(.old)と編集後をdiffコマンドで比較すると、以下のようになります。

# diff /etc/php-fpm.d/www.conf.old /etc/php-fpm.d/www.conf
78c78
< pm.start_servers = 5
---
> pm.start_servers = 10
83c83
< pm.min_spare_servers = 5
---
> pm.min_spare_servers = 10
88c88
< pm.max_spare_servers = 35 
---
> pm.max_spare_servers = 70

以下のコマンドを実行し、変更した設定を反映します。

# /etc/init.d/php-fpm reload

注意点

「pm.start_servers」の数値は、「pm.min_spare_servers」より大きく、「pm.max_spare_servers」より小さい必要があります。これに反した設定をすると設定反映時に以下のように怒られるので、注意が必要です。

# less /var/log/php-fpm/error.log
[29-Aug-2013 10:57:02] ALERT: [pool www] pm.start_servers(50) must not be less than pm.min_spare_servers(2) and not greater than pm.max_spare_servers(5)

nginx の人気記事

  1. sudoユーザーを追加する方法
  2. nginxの設定と使い方
  3. Windows10上でLinuxを実行(Linux用Windowsサブシステム)
  4. nginxとApacheの性能比較
  5. PHP-FPM - server reached pm.max_children - Warningエラー対処法

関連記事(一部広告含む)