we are talking about the horizontal scalable deployment of moodle > 2.7.
Horizontal Scaling : we are putting more than one computing machine to respond the request.
Challenges : there are lots of, as, how the session will maintain, how the media, how the database etc.
Horizontal scaling is dependent upon the Application we are utilising, in our case, this is moodle.
Moodle has three major component
- Code base, served by a web server
- Database, commonly mysql/postgre served by database server
- File Data, any file that we upload in moodle, like, course images, resource, assignment etc or other sort of files that we use to serve the user request including session file (if session is handled by File System)
Although we are talking about AWS, except the aws component, other things will be same for horizontal scaling in any environment.
there are two parts,
- Horizontal Scaling for Web Server
- Horizontal Scaling for Database Server
In this part, we will focus on Horizontal Scaling of Web Server.
Challenges for Web Server scaling in case of moodle
- Session Management [already under moodle data folder] – [AWS – EFS]
- File Data or dataroot or moodledata – [AWS – EFS]
- Cron – [on the machine that is out of auto scaling group]
- Caching part [ redis-over-efs-for-caching-in-moodle-cluster-solution]
So , now you can think of, you need to put ALB with set of ec2 for webserver scaling. following is the complete guide to setup this architecture on aws.
This above guide mention about memcache, that is not needed
so you will be setting up ec2 for webserver, EFS for moodle data, you need to change following settings in Moodle
// EFS [shared storage] $CFG->dataroot = '/var/www/moodle/data'; $CFG->cachedir = '/var/www/moodle/cache'; // requried lock, that's why on shared location $CFG->tempdir = '/var/www/moodle/temp'; // on ec2 [EBS] $CFG->dirroot = '/var/www/moodle/html' ; $CFG->localcachedir = '/var/www/moodle/local' ;
[CLI ] make sure to put the cron on the machine that is part of Target group but out of auto scaling group so that it does not remove due to scale-in.
[If you are using HTTPS] , and using your certificate at ELB. ending the SSL connection there, So, your site is utilising HTTPS but it ends at ALB. so put
$CFG->sslproxy = true; // if ssl ends at load balancer
The another Important Factor is the IP logged in moodle logs, as the primary request will be at elb, you may need to change the following settings,
SiteAdministration > Server > HTTP > Logged Ip Address Source