How and where to configure pm.max_children for php-fpm with Docker?
Solution 1:
I may be wrong, but assuming you're using the official PHP images those pm settings should be placed inside the /usr/local/etc/php-fpm.d/
directory inside a file with conf extension. According to PHP docs, those settings are FPM related and although they use php.ini
syntax, they should be placed in a different file, so I believe that your pm settings are being ignored. This Dockerfile in PHP helped me to find out where are those conf files supposed to be.
I'd check if you have a /usr/local/etc/php-fpm.d/www.conf
file inside your container where that max_children
is now set to 5
. If that is so I guess you could modify your Dockerfile to copy a new www.conf file that sets a higher value for pm.max_children
.
Solution 2:
I find clearer to overwrite specific settings using the file that ships with the official php:7.3-fpm
image: /usr/local/etc/php-fpm.d/zz-docker.conf
This file ends with something like:
[www]
listen = 9000
So we can just append it with exactly what we need to set for the www pool.
For instance:
# SETUP PHP-FPM CONFIG SETTINGS (max_children / max_requests)
RUN echo 'pm.max_children = 15' >> /usr/local/etc/php-fpm.d/zz-docker.conf && \
echo 'pm.max_requests = 500' >> /usr/local/etc/php-fpm.d/zz-docker.conf
I think it's simpler and clearer.