Question

Trying to set max_children and related settings

Posted July 14, 2021 59 views
UbuntuPHP

We have a client POUNDING our API. And we’re seeing issues with that. Error logs looks like this:

[13-Jul-2021 21:51:22] WARNING: [pool freshworks] seems busy (you may need to increase pm.startservers, or pm.min/maxspareservers), spawning 8 children, there are 0 idle, and 4 total children
[13-Jul-2021 21:51:23] WARNING: [pool freshworks] server reached pm.max
children setting (5), consider raising it

According to PHPINFO this is the php conf:

/etc/php/7.4/fpm/php.ini

And that file has:
include=/etc/php/7.4/fpm/pool.d/*.conf

And in both of these files:
/etc/php/7.4/fpm/pool.d/www.conf
/etc/php/7.4/fpm/pool.d/freshworks.conf

We’ve updated to:
pm = ondemand
pm.maxchildren = 40
pm.start
servers = 15
pm.maxspareservers = 25
pm.max_requests = 600

We’ve restarted but the same errors persist.

What are we missing or overlooking?

2 comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @KyleB,

https://www.php.net/manual/en/install.fpm.configuration.php

pm.max_requests:

The number of requests each child process should execute before respawning. This can be useful to work around memory leaks in 3rd party libraries. For endless request processing specify ‘0’. Equivalent to PHPFCGIMAX_REQUESTS. Default value: 0.

pm.max_children:

The number of child processes to be created when pm is set to static and the maximum number of child processes to be created when pm is set to dynamic. This option is mandatory.

This option sets the limit on the number of simultaneous requests that will be served. Equivalent to the ApacheMaxClients directive with mpmprefork and to the PHPFCGI_CHILDREN environment variable in the original PHP FastCGI.

From the above explanation, it seems you should increase the max_requests a bit.

Additionally, if this pounding of your API is not legit, you should block the IP that’s doing it or is this a legit behavior?