I'm trying to enable dynamic process management for php-fpm v7.3. Here's my php-pm.ini

pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 498

The problem is that I can't seem to confirm my fpm is seeing the changes. I can see that it's parsing the ini file:

$ docker-compose exec web php -i | grep "pm."

Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,

Looking at the phpinfo() service by fpm I don't see any of the pm. settings at all. How can I verify these settings are being picked up? And if they are but wouldn't show here, how can I prove it?

  • It is not possible as far as i know... – Andreas Rehm Dec 30 '18 at 16:42

You will not see these settings with php -i, because it's rather code related settings. Try setting pm.status_path = /status and then go to your http://localhost/status URL and there you will see your php-fpm options.

also you can look at process list to see which config file is currently used with command ps aux | grep php-fpm | grep master or you will see it in output of command php-fpm -t.

Of course you have to pass it to your docker container.

Edit by OP/Webnet

This solution led me part of the way, but there were other pieces that helped me solve it. Since this took me down the initial path I want to make sure patok gets credit so I'll expand on the solution here.

Rather than loading an additional ini file via /usr/local/etc/php/conf.d/, what I needed to do was modify fpm's configuration at /usr/local/etc/php-fpm.d/www.conf inside my container (you could add an additional .conf file if you want, but I didn't). Adding this to the dockerfile did the task:

RUN sed -i -e 's/pm = .+?/pm = dynamic/' \
 -e 's/pm\.max_children = \d/pm\.max_children = 35/' \
 -e 's/pm\.start_servers = \d/pm\.start_servers = 10/' \
 -e 's/pm\.min_spare_servers = \d/pm\.min_spare_servers = 5/' \
 -e 's/pm\.max_spare_servers = \d/pm\.max_spare_servers = 20/' \
 -e 's/pm\.max_requests = \d/pm\.max_requests = 500/' \
 -e 's/pm\.process_idle_timeout = .+?/pm\.process_idle_timeout = 10s/' \

I was able to confirm this solution worked by following the practices outlined in PHP-FPM: Process Management which included using ab -n 10000 -c 200 http://localhost/index.php to simulate 10k requests to my site, enabling me to use docker-compose exec web ps aux | grep php-fpm (as mentioned by patok) to see that the number of fpm processes had indeed been increased to handle the load.

  • Setting pm.status_path seems to not be making it past my Laravel app to fpm. I'm seeing my application's 404 page. My nginx config forwards requests to localhost:9000 so I should be able to execute docker-compose exec web curl localhost:9000/status and see the page. But that returns a curl: (56) Recv failure: Connection reset by peer. FYI web has both fpm and nginx running on it. – Webnet Jan 4 '19 at 3:23
  • php-fpm shows the file /usr/local/etc/php-fpm.conf in use, but I have configured fpm to load multiple files. php -i | grep ini in the container shows that /usr/local/etc/php/conf.d/php-pm.ini is being parsed, which is where the config is. – Webnet Jan 4 '19 at 3:29
  • docker-compose exec web ps aux | grep php-fpm only shows 3 total processes, 1 master and 2 children which isn't what's in my config which I suppose means it's not being read as expected. – Webnet Jan 4 '19 at 4:03
  • Main php-fpm.conf (/usr/local/etc/php-fpm.conf in your case) is usually being used for some global configuration and also for inclusion of files in conf.d (/usr/local/etc/php/conf.d/), so check your main config file for include directive (it should be set to something like include=/usr/local/etc/php/conf.d/*.ini). Then you could say, that your php-pm.ini inside conf.d directory is being properly loaded. Although I'm not sure about file extentions used - php-fpm, at least from what I can see on our Ubuntu and CentOS servers, use .conf not .ini extension. So be aware of this as well. – patok Jan 4 '19 at 10:43
  • Got it working! Thanks for the help - I submitted edits to your original answer to cover what I ended up doing to make it work. Thanks for the help! – Webnet Jan 5 '19 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.