I’m about to start building a test load balanced Moodle deployment.
is some great official
Moodle documentation, and some of the forum posts here are very
insightful as well.
After reading through much
of that, I have
questions I’d like to ask
to check a few things
with you guys.
Firstly a session cache question. When using a cluster of front end Moodle web servers, is it advisable to always use a shared session cache? Is this the ‘done thing’? Certainly a shared session cache would make load balancing simpler. It would make the Moodle front end stateful, and the load balancer would not need to use persistence / session affinity / sticky sessions. Simple round robin load balancing would work great in this case.
Secondly a question about load balancing methods. Several forum posts on here mention using LVS/NAT for load balancing a cluster of Moodle front end web servers. Is anyone using or has tried using LVS/DR instead? I think that it should work perfectly, provided that the ARP problem is resolved on each web server as is required for any LVS/DR deployment. LVS/DR offers greater raw throughput than LVS/NAT, so it would be a very attractive solution for big Moodle deployments if it works.
One final question about how current and new Moodle clusters are actually being load balanced today. Are load balanced Moodle deployments still using LVS for the load balancing function, or is it more common to use a layer 7 full proxy solution like HAProxy these days?
Thank you for any advice or insight you can provide.
To be perfectly honest I don't know what the Moodle session cache is for. The limited docs just say it's for some mysterious data sets that (presumably) act as session data without actually using the native sessions.
However, PHP sessions absolutely need to be shared or it just won't work (you'll get logged out if the load balancer bumps you to a different web server) so I assume that the session cache must be the same. Generally speaking, I would suggest it make sense just to stick in a box running Redis or something and that should do the job nicely.
The Moodle documentation I read to get some information on load balancing was the page on Performance recommendations:
and the page on Caching:
Both of those pages give some hints and tips on putting together a Moodle cluster (front end and back end) and implementing a load balancer. The Performance recommendations page links to some forum discussions specifically about load balancing, so that was really useful to read.
Thanks! Will be useful to others looking for load balancing for Moodle.
In fact I already gave this thread as reference in a related discussion: "Installing Moodle on different VMs with load balancer mission" https://moodle.org/mod/forum/discuss.php?d=378068. See Howard's reply there.
Ha Proxy or Apache mod proxy should be fine
But if you have an apache cluster or multiple servers, one would normally either cluster these, in which case the Moodledata (Session cache), would be shared anyway
Or you would have a shared NFS server to host your moodledata and that would be shared
Or you could have local session cache on each web server and set Mod Proxy with sticky sessions
Or use Memecache server with sticky sessions from the LB
I have setup many clusters and these questions always come up. I think it is easier to cluster the webs using OCFS2 or GlusterFS and mount an ISCSi lun directly on a SAN to have the Moodledata on and share this with the webs.
But its been a while so my memory has run out of RAM