Applicable to:
- Plesk for Linux
Question
How to calculate pm.max_children
value on a Plesk server?
Answer
-
Calculate and change the value of the parameter
pm.max_children
based on the amount of RAM on the system.
The following command will help to determine the memory used by each (PHP-FPM) child process:# ps -ylC php-fpm --sort:rss
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
S 0 931 1 0 80 0 87040 99039 ep_pol ? 00:00:00 php-fpmNote: The RSS column shows non-swapped physical memory usage by PHP-FPM processes in kiloBytes.
-
If on average each PHP-FPM process takes ~85MB of RAM on the server, the appropriate value for
pm.max_children
can be calculated as follows:CONFIG_TEXT: pm.max_children = Total RAM dedicated to the web server / Max child process size
For example, if the server has 8GB of RAM and 6GB of RAM is planned to be allocated to the web server, then the
pm.max_children
value will be the following:CONFIG_TEXT: pm.max_children = 6144MB / 85MB = 72
Note: The received number of children has to be distributed among all websites on the server. Keep in mind that most popular websites require more children while others, non-popular ones - less.
Example of how to divide the result between websitesThere are 3 domains on the server:
-
example.com
A popular online shop. The number of visitors is very high.
-
example.net
A home page of some person. The number of visitors is almost zero.
-
example.org
A little jewelry online shop that was created a month ago. The number of visitors is not high.
Is the appropriate
pm.max_children
value was calculated to be 72, in this case, it is required to allocate children, for example, as follows:-
For
example.com
:50 children.
-
For
example.net
:2 children.
-
For
example.org
:20 children.
-
-
To apply changes for
pm.max_children
value follow steps from the articles:- For a domain/multiple domains via the Service plan: How to customize PHP-FPM pool settings for a domain through Plesk graphical interface?
- For all domains: How to apply PHP-FPM pool settings for all domains in Plesk?
Comments
2 comments
can you please explain how you calculate "if the server has 8GB of RAM" to get 6144MB ?
Did you subtract some MB for operation system or is is a mistake ?
Hello Marcus Dressler,
Some memory should be left for the system to breathe. You need to take into account any other services running on the machine while calculating memory usage.
The value of 6 GB was taken as an example here. It may be adjusted in accordance with your needs.
Please sign in to leave a comment.