Php-fpm configurations issue

Php-fpm configurations issue

av Gaurav Shinde -
Antall svar: 3

I have my moodle site hosted on a server of 30GB RAM. I have also installed php-fpm on the server. When I was testing the site for different user sets, I was getting a warning in the error logs stating 'WARNING: [pool www] server reached pm.max_children setting (5), consider raising it'.

After that, I tried changing the values of the variables(max_children,min_spare_servers,max_spare_servers,start_servers) in the 'www.conf' file. When I performed the tests again, I was getting this in the error logs - 'WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 7 total children'

Therefore, what would be the solution to this problem and also what would be the correct configurations of the variables in the www.conf file?


Gjennomsnittlig vurdering: -
Som svar til Gaurav Shinde

Re: Php-fpm configurations issue

av Michael Spall -
Gaurav,

You didn't specify which version of Moodle or PHP you are using. This advice is if you are on Moodle 3.9 or 3.10 and PHP 7.2 - 7.4 and Apache 2.4. I would check to see which mpm module you are using. We saw huge performance improvement using mpm_event_module vs mpm_prefork_module. 

In httpd.conf make sure that you the mpm you are using is configured correctly. Something like this, using your numbers instead of xxx:
<ifModule mpm_prefork_module>
    MaxRequestWorkers xxx
    ServerLimit xxx
</ifModule>

<ifModule mpm_event_module>
    MaxRequestWorkers xxx
    ServerLimit       xxx

    StartServers      xxx
    MinSpareThreads   xxx
    MaxSpareThreads   xxx
    ThreadLimit       xxx
    ThreadsPerChild   xxx

    MaxConnectionsPerChild xxx
</ifModule>

Mare sure these variables are set correctly for your site:
pm.max_children
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers
pm.max_requests
In a RHEL type system they are in /etc/php-fpm.d/www.conf

I found Apache2 and php fpm performance optimization helpful along with the spreadsheet from Thomas Herweg. You will need to tune these ideas with a system under expected load.
Gjennomsnittlig vurdering:Useful (1)
Som svar til Gaurav Shinde

Re: Php-fpm configurations issue

av Alex Rowe -
Without knowing the values that you have set for these options (or seeing the config file), it's hard to provide much input.

There are lots of guides online about how to properly configure PHP-FPM.

The main ones to look out for would be if MySQL is used on this server, you need to take it's memory into account when working out PHP max_children. Also if you have a high Opcache or other services (redis, other sites etc), they also need to be taken into account.

Depending on what you use the server for, you could also set FPM to static rather than dynamic, but that's up to you.

apache2buddy I also don't think works for event/worker MPM and PHP, it's only for prefork (but I may be wrong).
Gjennomsnittlig vurdering:Useful (1)