Adjust PHP setting pm.max_children

Preface

The PHP setting pm.max_children defines the maximum number of PHP child processes available at the same time. If your website has a high number of users, several PHP-FPM processes must be executed to process the requests. The setting ensures that the number of simultaneously executed processes is monitored and optimized so that the server is not overloaded by a high number of users, for example.


If too many PHP child processes are executed at the same time, this can overload the server and affect the operation of your website. We recommend optimizing the setting so that it does not exceed the memory (MiB) available for PHP-FPM multiplied by the defined memory_limit.


To adjust the PHP setting pm.max_children, first log in to our customer center at account.creoline.com with your access data.


Use the navigation to select your server under Server for which you want to change the PHP settings. Then open the Plesk Control Panel via the Plesk Control Panel menu item.


If the menu item is not displayed on your server, you will find further options for logging in in the article Logging in to the Plesk Control Panel.



Customization for a single domain

Once you are logged in to Plesk, you can select the domain via the global search or the Websites & Domains menu item.


Plesk - Websites & Domains - PHP Settings


You can use the PHP settings button to adjust the general PHP settings and the PHP setting pm.max_children.


Plesk - PHP-FPM-Settings - pm.max_children


The value pm.max_children defines the maximum number of concurrent PHP processes. This value is freely definable and is specified in the unit number.



Calculation pm.max_children (Maximum)

The maximum possible value for pm.max_children can be calculated using the following formula:

(RAM - 2 GiB) / Memory Limit = Maximum value for pm.max_children
      ^ ^ ^
      | | |
      | | |
      | | | └ Defined PHP memory limit value
      | Reserved working memory for other services (value may vary)
      Working memory of the entire server



We recommend calculating the number of pm.max_children with the following formula:

(memory - 2 GiB) / PHP process size = Recommended value for pm.max_children
      ^ ^ ^
      | | |
      | | |
      | | | └ Average PHP process size
      | Reserved working memory for other services (value may vary)
      Working memory of the entire server


The average PHP process size can be determined using a PHP profiler, for example. We recommend using Tideways for PHP profiling. A Tideways license can be purchased directly from our support team, see also: Price list for additional services and special services


After the settings have been saved, the web server automatically reloads the configuration using a graceful restart, so that existing requests are not aborted but paused.



Example calculation pm.max_children

Parameter Value Explanation
Server memory 16,384 MiB 16 GiB
Reserved memory 6,144 MiB 6 GiB
Average PHP process size 100 MiB


# Calculation of the available memory for PHP
16,384 MiB - 6,144 MiB = 10,240 MiB

# Calculation of the recommended value for pm.max_children
10,240 MiB / 100 MiB = ~102 pm.max_chidlren



Further setting options

Under the PHP settings, it is also possible to adjust the pm.max_requests, the desired pm process manager or the pm.start_servers, pm.min_spare_servers and the pm.max_spare_servers.


PHP setting Description
pm Defines how the process manager manages the number of child processes.
Possible values: static, ondemand, dynamic - This setting is mandatory.

static - the number of child processes is fixed by pm.max_children

ondemand - the child processes are started as soon as they are needed, in contrast to dynamic, where pm.start_servers processes are already started at the beginning.

dynamic - the number of child processes is set dynamically, based on the following settings:
pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers
pm.start_servers The number of child processes that are created at startup. Only used if pm is set to dynamic.

Default value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.min_spare_servers The desired minimum number of server processes in idle mode. Is only used if pm is set to dynamic. Also mandatory.
pm.max_spare_servers The desired maximum number of server processes in idle mode. Only used if pm is set to dynamic. Also mandatory.