Moodle Horizontal Scalable Deployment on AWS stack

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

  1. Code base, served by a web server
  2. Database, commonly mysql/postgre served by database server
  3. 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

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

courtesy @aws-refarch-moodle

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 this line in moodle config.php

$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, To log actual Ip of the user in the moodle log table.

SiteAdministration > Server > HTTP > Logged Ip Address Source

Logged Ip Address

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *