Tuning Apache and php-fpm for Moodle

Tuning Apache and php-fpm for Moodle

by Alain Raap -
Number of replies: 2
Picture of Particularly helpful Moodlers

Who has experience with tuning Apache 2.4 and Php-fpm 7.1 on Redhat Linux? I'd like to know more about how to tune the parameters for the Php-fpm process manager and Apache mpm module. There are a lot resources on the internet about this subject, but not for the Moodle environment. I've already read the performance recommendations, but would like to hear about the experiences of Moodle users on this subject.

Average of ratings: Useful (1)
In reply to Alain Raap

Re: Tuning Apache and php-fpm for Moodle

by Mathew Gancarz -
Picture of Core developers

Only tweaks I use in Apache are:

Timeout 300
MaxConnectionsPerChild 1000

StartServers 25
MinSpareServers 25
MaxSpareServers 50


Timeout is due to generating response pages/downloading responses from Questionnaire plugin taking a while for courses with hundreds of students.

The MaxConnectionsPerChild is used to limit memory leakage and the Servers settings are just so that the server jumps up ready for connections. I don't really have evidence to backup up the specific values for any of those but they've been working well for us for 5+ years.

Keep in mind settings will vary based on whether you are running one server or multiple ones. We run one apache web server, 10 vCPU, 32 GB Ram and using SSD local storage. MySQL DB on a seperate server but on the same virtual host. This serves about 3000 users annually, with about 10-30 average users on at one time within a 30 minute window, peaking at about 60-70.  

From my jmeter benchmark tests, this setup can handle about 100-150 concurrent users without significantly slowing down using a simulated mix of forum browsing/posting, quiz taking and scorm module viewing.

I'm still on PHP 5.6 but only tweaks I did there other than post_max_size/upload_max_filesize and max_execution_time is the opcache settings, the only changes from defaults that came with it are:

opcache.max_accelerated_files =  8000
opcache.revalidate_freq = 60

Based on https://docs.moodle.org/en/OPcache 


Average of ratings: Useful (2)
In reply to Mathew Gancarz

Re: Tuning Apache and php-fpm for Moodle

by Alain Raap -
Picture of Particularly helpful Moodlers

Hi Mathew,

Thanks for sharing your experiences and if you want to know more about our Moodle stack, just let me know or send me a PM.