Jared Meyering
Jared Meyering

Reputation: 1321

php7.1-fpm spawning max children when concurrent users

Running php7 on an AWS m4large instance and running into php7.1-fpm issues.

It serves a single connection just fine but once I start running even a minimal amount of traffic fpm starts spawning a lot of children.

I'm just serving a phpinfo page so there is no significant memory usage going on here.

If I run ab -n 10 -c 10 https://example.com/index.php I immediately get the following messages in my fpm log.

[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

Here are my fpm settings

[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

I've been playing with my min/max servers setting and it doesn't matter if it 50 or 100.

Any help with this? What could be causing this to crash?

Upvotes: 1

Views: 2709

Answers (1)

Jared Meyering
Jared Meyering

Reputation: 1321

My issue was an issue with my code which internally created an infinite recursion of requests. This was not related to fpm whatsoever.

Upvotes: 3

Related Questions