php7.1-fpm在并发用户时产生最大子项

时间:2017-04-27 16:06:58

标签: php nginx fpm

在AWS m4large实例上运行php7并运行到php7.1-fpm问题。

它提供单一连接就好了但是一旦我开始运行甚至最小量的流量fpm开始产生很多孩子。

我只是提供phpinfo页面,因此这里没有显着的内存使用情况。

如果我运行ab -n 10 -c 10 https://example.com/index.php,我会立即在我的fpm日志中收到以下消息。

[27-Apr-2017 10:26:00] 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 12 total children
[27-Apr-2017 10:26:01] 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 17 total children
[27-Apr-2017 10:26:02] 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 22 total children
[27-Apr-2017 10:26:03] 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 27 total children
[27-Apr-2017 10:26:04] 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 32 total children
[27-Apr-2017 10:26:05] 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 37 total children
[27-Apr-2017 10:26: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 42 total children
[27-Apr-2017 10:26: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 47 total children
[27-Apr-2017 10:26:08] WARNING: [pool www] server reached pm.max_children setting (50), consider raising it

以下是我的fpm设置

[global]
 pid = /var/run/php/php7.1-fpm.pid
 error_log = /var/log/php7.1-fpm.log
 syslog.ident = php-fpm
 syslog.facility = 24
 log_level = NOTICE
 process.max = 0
 process.priority = undefined
 daemonize = yes
 rlimit_files = 0
 rlimit_core = 0
 events.mechanism = epoll
 systemd_interval = 10s

[www]
 prefix = undefined
 user = www-data
 group = www-data
 listen = /var/run/php7.1-fpm.sock
 listen.backlog = -1
 listen.owner = www-data
 listen.group = www-data
 listen.mode = 0660
 listen.allowed_clients = undefined
 process.priority = undefined
 pm = dynamic
 pm.max_children = 50
 pm.start_servers = 5
 pm.min_spare_servers = 5
 pm.max_spare_servers = 35
 pm.process_idle_timeout = 10
 pm.max_requests = 0
 pm.status_path = undefined
 ping.path = undefined
 ping.response = undefined
 access.log = undefined
 access.format = %R - %u %t%m %r%s
 slowlog = /var/log/php-fpm/www-slow.log
 request_slowlog_timeout = 0s
 request_terminate_timeout = 0s
 rlimit_files = 0
 rlimit_core = 0
 chroot = undefined
 chdir = undefined
 catch_workers_output = no
 clear_env = yes
 security.limit_extensions = .php .phar

我一直在玩我的最小/最大服务器设置,如果它是50或100则无关紧要。

对此有何帮助?什么可能导致崩溃?

1 个答案:

答案 0 :(得分:1)

我的问题是我的代码问题,它在内部创建了无限递归请求。这与fpm无关。