This post will cover how to modify the value of pm.max_children for Linux PHP 8 app services.
If you notice slow performance on your PHP app service and the below warning message in your log files you might want to consider increase this setting.
2023-01-06T16:41:41.955903016Z [06-Jan-2023 16:41:41] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
Go to the Kudu (Advanced Tools) site for the App Service and select WebSSH from the menu.
- Copy the default www.conf file under the /home folder so it can be persisted after a container restart.
root@806c3760a0b9:/home# cp /usr/local/etc/php-fpm.d/www.conf /home
Modify the www.conf file you copied under /home and using a text editor of your choice. Change the value of pm.max_children to the desired value and save your changes.
pm.max_children = 50
- Create a startup script under the /home directory and add the below content. In this example the script filename is called startup.sh .
root@806c3760a0b9:/home# vi startup.sh
#!/bin/bash # Copies our modified www.conf file to the correct location. cp /home/www.conf /usr/local/etc/php-fpm.d # Kills the php-fpm process so it can be restarted. pkill -o -USR2 php-fpm
Reference your script on container startup by naviagating to the
App Service Azure Portal -> Settings -> Configuration -> Startup Commandsection. Then enter the full path of the script you created and save the changes.
What should the value of this pm.max_children be?
This is dependant on the application and the amount of memory allocated to the app service plan. Below are a few open source articles that can help your team make an informed decision.
- Adjusting child processes for PHP-FPM (Nginx) · MYSHELL.CO.UK
- Finding the correct pm.max_children settings for PHP-FPM - Chris Moore
- How to Change the PHP-FPM max_children Setting - ServerPilot
The only thing to be aware of is that increasing this setting might raise the memory usage on the app service plan.
We recommend your team monitor the app service plan memory usage when expirementing with this value. Monitor apps - Azure App Service | Microsoft Learn