Load balancing Moodle's Learning Management System (LMS)
Useful resources
About Moodle’s Learning Management System (LMS)
Moodle LMS is an open source learning platform used to create personalized learning environments. The application is designed to provide a single, secure, integrated learning platform which contains learner-centric tools and resources, and collaborative learning environments to empower both teachers and students.
We love it because it integrates really well with other external applications to achieve additional functionality. It’s also web-based which means it can be accessed from anywhere in the world (except for those using Geo-blocking).
Key benefits of load balancing
Here are a few key benefits:
- Ensures the application is always available
- Provides a stable, optimal performance
- Ability to isolate servers which reduces risk when performing upgrades/maintenance
- Scalability
How to load balance Moodle’s learning application system (LMS)
There are two ways to configure the load balancer, depending on your requirements:
- An insecure Layer 7 HTTP through and through, with both the load balancer and the application servers on port 80.
- Layer 7 HTTPS.
For full details, refer to this blog: Load balancing Moodle’s learning application system (LMS). A summary of the configuration is noted below.
L7 HTTP deployments
- Deploy the Loadbalancer and get through the deployment steps and setup your management interface, gateway and Domain Name System (DNS).
- Once connected to the WebUI of the Loadbalancer, navigate to Cluster Configuration>Layer 7 Virtual Services, and click on the Add a new Virtual Service button.
- Enter the appropriate Label and IP address, leave the port field set to 80, protocol to HTTP, then click on the ‘Update’ button. After doing so you will be prompted to ‘Reload HAProxy’, so click on that as well.
- Navigate to Cluster Configuration>Layer7 Real Servers and click on the ‘Add a new Real Server’ button next to the newly created VIP. Enter the IP address of the Real Server that is serving Moodle, leave all other fields as they are, and click the ‘Update’ button. After doing so you will be prompted to ‘Reload HAProxy’, so click on that as well.
Repeat this step as many times as needed to add all of your Real Servers.
- Go to Cluster Configuration, Layer 7 Virtual Services and click on ‘Modify’ next to the newly created Moodle VIP.
Under ‘Persistence’, we can either use: Source IP, Application Cookie or None. You will need to set the timeout to be the same as the Inactivity Timeout set in Moodle under the Online users tab during your configuration. Note, you also have a ‘?’ next to persistence where all methods are explained.
After selecting the desired value and persistence type, click on ‘Update’ and you will again be prompted to ‘Reload HAProxy’.
- Now navigate to the System overview.
- (Optional) If transparency is required and you need the originating IP address of the client, you need to navigate to Cluster Configuration>Modify the Moodle VIP, scroll to the bottom, click on the ‘Advanced’ dropdown, and simply ‘Enable Transparent Proxy’.
Please be advised that additional steps need to be taken on the Real Servers in order for this to work. The gateway of the RIP needs to be an IP address from the Loadbalancer; please refer here to page 144 of our administration manual.
L7 HTTPS deployments
For L7 HTTPS deployments, steps 1 to 7 (above) still need to be followed. However, these additional steps are then required to be taken on the Loadbalancer:
- Go to Cluster configuration, navigate to ‘Layer 7 Virtual Services’, and click modify to the newly created VIP, scroll to the bottom, click on the ‘Advanced’ dropdown, and set the ‘Force To HTTPS’ option to ‘YES’, and the redirect code to ‘302’.
If you try to access the VIP, it won’t work and you will get a ‘Refused connection’ error as additional steps are required.
- We need to create an SSL termination for the VIP in order to make the ‘Force To HTTPS’ option work, so please navigate to Cluster Configuration, SSL Termination and click on the ‘Add a new Virtual Service’ button on the right side.
- Add a label to your SSL Termination and from the ‘Associated Virtual Service’ dropdown select the Moodle VIP. Click on ‘Update’, and you will be prompted to ‘Reload HAProxy and STunnel’ on the blue banners on the top. After reloading both you will be able to access the VIP IP, and be redirected to HTTPS.
Note: the Moodle server needs to be configured to support SSL proxies, and to ensure that all URLs are HTTPS rather than HTTP. This configuration is stored in config.php which is located in the moodle/htdocs directory.
manual
Administration manual
Read manualblogs
Load balancing Moodle's learning application system (LMS)
Read blogUptime in education: resilient applications in schools, colleges and universities
Read blogConsiderations for higher education institutions rolling out virtual desktops
Read blogother
Load balancing for reliable and secure higher education applications
Read other