PHP 7.2 启动失败 pm.max_children > 506

PHP 7.2 fails to start when pm.max_children > 506

在 Debian 10 上,当我设置 pm.max_children = 507 或更多并尝试启动 php7.2-fpm 我收到以下错误:

-- The unit php7.2-fpm.service has entered the 'failed' state with result 'protocol'.
Sep 26 12:07:13 server.local systemd[1]: Failed to start The PHP 7.2 FastCGI Process Manager.
-- Subject: A start job for unit php7.2-fpm.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit php7.2-fpm.service has finished with a failure.

当我设置 pm.max_children = 506 或更少时,一切正常。

我的 www.pool 配置:

[www]

user = www-data
group = www-data

listen = /var/run/php7-fpm.sock
listen.owner = www-data
listen.group = www-data


pm = static
pm.max_children = 506
pm.max_requests = 1000

catch_workers_output = yes

我的服务器配置:

是什么原因造成的?对于可以启动多少 php-fpm children 是否有一些硬性限制?或者这是一些系统限制?能以某种方式增加吗(我有很多空闲内存)?

从长远来看,这 500 多个 php-fpm 儿童中的大多数可能会闲置,但如果您确实想增加数量,[=18= 还设置了其他限制]进程和操作系统。

Open File Descriptor Limit Set open file descriptor rlimit for the master process. Default value: the rlimit for the master process (from php-fpm.conf).

# in php-fpm.conf and pool.d/*.conf
rlimit_files = 131072
# the default value may be as low as 1024, and since each child will typically 
# open 2 files (stdin & stdout), and there are additional files being used, 
# 506*2 = 1012 +12 others seems very likely to be an issue.

您可能还需要启用 php-fpm(或其用户),以便能够通过编辑 /etc/security/limits.conf 文件来使用更多文件句柄,并为用户设置硬限制和软限制(www-data).