Automated Moodle AWS Cluster solution for E-learning company

Aug 13, 2024

How e-learning solution was improved with scalable, robust and highly-available automated Moodle AWS Cluster

In today's fast-paced educational landscape, e-learning platforms need to be scalable, robust, and highly available. I recently undertook a project to enhance an existing Moodle installation by creating an optimized automated AWS Cluster. This blog post details how I improved the e-learning solution, addressing critical issues and implementing automation to streamline management tasks.

Initial solution

Initially, the Moodle platform was hosted directly on a single EC2 instance connected to a shared database. This setup lacked a comprehensive architectural design, leaving room for inefficiencies and scaling challenges. While this configuration provided a basic working environment, it lacked the flexibility, scalability, and high availability required for robust e-learning platforms.

Addressing critical bug fixes

My first step was to tackle existing issues in the original Moodle installation. I've resolved deployment problems, fixed OPcache and PHP CLI execution issues, and corrected PHP.ini configuration errors. These fixes laid a solid foundation for a more stable Moodle environment.

IaC template and enhanced performance

I've made several key updates to the template to improve performance and resource utilization:

  • Updated to the latest MySQL version for improved database performance
  • Optimized instance types
  • Implemented a 'Retain' deletion policy to prevent accidental data loss
  • Migrated from S3-based deployment to AWS SAM for simplified resource management

Leveraging AWS SAM

One of the most impactful changes was the shift from S3-based deployment to AWS Serverless Application Model (SAM). This transition offers several benefits:

By using AWS SAM, I eliminated the need for manual S3 bucket selection and simplified the overall deployment process. SAM automatically creates necessary resources, reducing potential configuration errors and streamlining the setup.

Target solution

To address these limitations, the new solution is based on a modular infrastructure with reusable components, enabling scalability, high availability, and streamlined management. This architecture leverages various AWS services to create a more optimized and automated Moodle environment.

AWS Components Image Figure 1: AWS Components Schema

The diagram above illustrates the core elements of the infrastructure, including key AWS services like RDS for database management, ElastiCache for session management, and an Application Load Balancer (ALB) for efficiently distributing traffic across multiple availability zones.

The new AWS cluster includes:

  • A Virtual Private Cloud (VPC) to isolate resources securely
  • An EC2 Auto-Scaling Group for elastic expansion of Moodle application instances
  • A multi-AZ RDS setup to ensure database resilience and failover
  • A shared Elastic File System (EFS) for data storage that can be accessed across multiple instances
  • ElastiCache for handling session and application caching for better performance

These improvements are essential in creating a resilient, highly available, and fault-tolerant Moodle cluster.

AWS Target Solution Image Figure 2: AWS Target Solution Architecture Schema

The target solution diagram above represents the full architecture of the Moodle AWS Cluster. This architecture integrates load balancing, database replication across availability zones, and caching to ensure optimal performance and fault tolerance. Additionally, the cluster utilizes AWS Route53 and CloudFront for domain management and CDN caching, significantly improving the user experience by reducing latency.

Automation workflows

The project also involved implementing advanced automation workflows to streamline routine management tasks, such as deploying updates and scaling the platform. These workflows ensure smooth operation and reduce the need for manual intervention.

AWS Automation Workflow Image Figure 3: AWS Automation Workflow Schema

The automation workflow shown above is an example of the Moodle upgrade process. The schema given here is missing some unique features delivered to the client, but is good for the general representation.

I've created automation workflows to handle:

  • Moodle upgrades: minor and major flows
  • Toggling the platform online/offline
  • Enabling/disabling maintenance mode
  • Uninstalling missing plugins
  • Resetting user passwords

These automations reduced the manual effort required for routine maintenance and updates.

Results and summary

The optimized Moodle AWS Cluster delivers several key benefits:

  • Improved scalability to handle varying loads
  • Enhanced stability through critical bug fixes
  • Simplified management with automated routine tasks
  • Streamlined deployment process using AWS SAM
  • Future-proofed setup with easier upgrades and maintenance

By addressing these key areas, I've achieved a more robust, efficient, and manageable e-learning platform for the client's needs.