Deploying Moodle on Azure – things you should know
Published Aug 20 2019 05:41 PM 56.9K Views

Updated: December 9, 2022

 

Moodle is one of the most popular open-source learning management platform empowering educators and researchers across the world to disseminate their work efficiently. It is also one of the most mature and robust OSS applications that the community has developed and improvised over the years. We have seen customers from small, medium, and large enterprises to schools, public sector, and government organizations deploying Moodle in Azure. In this blog post, I’ll share some best practices and tips for deploying Moodle on Azure based on our experiences working with several of our customers.

 

Note: Versions 3.09 and 3.11 are currently supported, and we are working on support for version 4.0. 

 

Prerequisites

Before you deploy, customize, and consume this solution, be sure that you have solid understanding of Azure Resource Manager (ARM) templates.

 

Provisioning a Scalable Moodle Cluster on Azure

To simplify the deployment and provisioning of a Moodle Cluster on Azure, our engineering team has developed some canned Azure Resource Manager (ARM) templates and that are available in our GitHub repository.

 

If you have Azure account, you can deploy Moodle via the Azure portal using the buttons in the table below, or you can deploy Moodle via the CLI. Please note that while you can use an Azure free account to get started, the template configuration you choose you may well require an upgrade to a paid account.

 

Below is a list of pre-defined deployment options based on typical deployment scenarios (i.e. dev/test, production etc.). All configurations are fixed, and you just need to pass your ssh public key to the template to log in to the deployed VMs. For production deployments, it is highly recommended to use the Large-size or Maximum template, which will provision high performance SKUs and configure the environment for high availability.

 

Deployment type

Description

Estimated Cost

Launch

Minimal

Uses NFS, Azure Database for MySQL - Flexible Sever (Burstable SKU 2 vCores), and a smaller autoscale web frontend VM SKU (1 core) that provides for faster deployment (less than 30 minutes) and requires only 2 VM cores, which currently works even in a free trial Azure subscription.

link

JimToland_0-1670618849612.png

 

Small- to Mid-size

Supports up to 1K concurrent users; uses NFS (no high availability) and Azure Database for MySQL - Flexible Server (General Purpose 8 vCores), without other options such as elastic search or Redis cache.

link

JimToland_1-1670618849614.png

 

Large-size (with high availability)

Supports over 2K concurrent users; uses Gluster (for high availability, requiring 2 VMs), Azure Database for MySQL - Flexible Server (General Purpose16 vCores), and Redis cache, without other options such as elastic search.

link

JimToland_2-1670618849615.png

 

Maximum

Uses Gluster (for high availability, adding 2 VMs for a Gluster cluster), Azure Database for MySQL - Flexible Server (Business Critical 64 vCores), Redis cache, elastic search (3 VMs), and fairly large storage sizes (both data disks and DB).

link

JimToland_3-1670618849616.png

 

 

 

NOTE: The above deployment templates use hard-coded Azure Database for MySQL - Flexible Server SKUs for easier configuration and quicker deployment of Moodle workloads. If your deployment fails for any reason, please revert to the fully configurable template if possible, and change the Azure Database for MySQL - Flexible Server parameters accordingly.

 

Each version of the template deploys the following architecture in Azure.

 

Picture2.png

 

Configuring Azure Database for MySQL for performance and scale

Moodle supports multiple databases such as MySQL, PostgreSQL, and SQL Server, but the best performance and scale for Moodle is observed with Azure Database for MySQL. As a result, MySQL is a preferred choice for customers and the community when deploying Moodle for large number (1K – 10K) of concurrent users. The deployment templates use Azure Database for MySQL - Flexible Server, a fully managed database service with features such as high availability, elastic scaling, and automatic backups. Leveraging a managed service ensures that you don’t have to worry about managing your database for backups and high availability or even setting up additional database monitoring.

 

When provisioning Azure Database for MySQL - Flexible Server for Moodle deployments, consider the information in the following table, which identifies the recommended tier for the best price to performance ratio based on your scenario.

 

Concurrent users

Compute (vCores)

Storage tier

< 1K users

8 vCores – General Purpose tier

1TB

1K – 2K users

16 vCores – General Purpose tier

2TB

2K – 5K users

32 vCores – General Purpose tier

2TB

> 5K users

32 - 64 vCores – Business Critical tier

2TB

 

Azure Database for MySQL - Flexible Server supports a compute size from 1 vCore up to a maximum of 96 vCores, up to 16 TiB of storage, and up to 48000 IOPs at this time. You can independently tune instance and SKU sizing, storage sizing, and the IOPS configuration for your Moodle workloads to meet your end-user needs.

 

In addition to server scaling, server parameter configuration and other considerations are also important to ensuring the best performance of the Moodle application, as recommended in the official documentation.

 

  1. In the Azure portal or the Azure CLI, enable and configure the query cache:
    query_cache_type = ON
    query_cache_size = 36M
    query_cache_min_res_unit = 2K
  2. Increase the size of the open table cache:
    table_open_cache = 1024
  3. Ensure that the slow_query_log parameter is set to OFF, otherwise it may cause additional IO overhead and slow down the server for scenarios with a high number of concurrent users.
  4. Determine the number of temporary tables saved to disk by checking the value of created_tmp_disk_tables in the SHOW GLOBAL STATUS output. If the number of temporary tables is more than about 5% of the total, then increase the value of the tmp_table_size parameter until you see a reduction. Note that this will impact memory usage.
  5. If you’re migrating or restoring an existing Moodle database to Azure Database for MySQL, it’s recommended to perform OPTIMIZE ALL on the tables in the database after the process is complete. For new deployments with no preexisting data, you can skip this step.
  6. It’s recommended to periodically check in on how your flexible server instance are running by leveraging Azure Database for MySQL - Flexible Server’s in-built monitoring capabilities, such as the integrations with Azure Monitor Workbooks. Workbooks provide a canvas for analyzing data and creating rich visual reports within the Azure portal.
  7. It’s also recommended to ensure that your MySQL database isn’t flooded with queries by leveraging Redis Cache for Session handling and OPCache. Caching can help alleviate pressure on the backend database and improve the overall performance and scale of the application.

 

Cost optimization considerations

  • Leverage Autoscaling IOPS to make it easier and more cost-effective to run your workloads on Azure Database for MySQL - Flexible Server. With Autoscaling IOPS, you only pay for the IO that you use, with no need to provision and pay for resources that aren’t fully used, which saves money and time. In addition, with this feature, your application can achieve consistent performance because there’s additional IO available to the workload at all times.
  • With Azure Database for MySQL - Flexible Server, you can independently change the compute tier, scale the compute size (vCores and memory) up and down, and set the backup retention period from 1 to 35 days. You can also scale IOPs independently of storage, which can improve the performance of IO intensive operations in an environment with high concurrency.
  • Deploy low intensity workloads using the Burstable SKU tier. With Azure Database for MySQL - Flexible Server, you can provision a low cost B1S SKU, which starts at approximately $12 USD per month.
  • You can stop a flexible server for up to 30 days when it’s not in use. When you restart the server within 30 days, your application will be ready to go. While the server is stopped, its compute is not billed, though billing continues for storage, which contains the data files required when restarting the server.
  • While you can set up your flexible server using a High Availability configuration, the associated billing includes compute costs and storage costs for the primary and standby instances. To minimize costs, based on your application needs, consider setting up your flexible server using a non-High Availability configuration.
  • With Azure Database for MySQL, you can save up to 67% on compute costs by prepaying for compute resources rather than using pay-as-you-go prices. With reserved instances, you make an upfront commitment to using your MySQL flexible server for a period of one or three year, and in return you get a significant discount on compute costs. You can also exchange or cancel your reservations as business needs change. To determine the discount that applies to your scenario, in the Azure portal, on the Reservations blade, view the savings per pricing tier and region.

 

Supportability of the solution

The Moodle deployment templates shared in this blog post are not a managed solution. Moodle is a third-party software platform, and Microsoft Customer Support and Services (CSS) will not support the solution. Microsoft only provides support for the underlying infrastructure and the services used in the solution. The solution is open-source and maintained by the community of experts in GitHub, and for any issues, we recommend that you open an issue with GitHub.

 

Please see the Readme and detailed FAQs documentation before proceeding with deploying the solution in a production environment.

 

FAQ

Can I customize the templates based on my requirements?

Yes, these templates are highly configurable. For full details about the configuration options, see the Moodle documentation (specifically, the Parameters documentation).

 

How can I find the admin password of the Moodle site?

After deploying the Moodle template, you can find the Moodle Administrator password and other output parameters by using the following command.

 

MOODLE_DATABASE_ADMIN_PASSWORD="$(az group deployment show --resource-group $MOODLE_RG_NAME --name $MOODLE_DEPLOYMENT_NAME --out tsv --query *.outputs.databaseAdminPassword.value)"

 

To use the command, you’ll need to download and install the Azure CLI and provide your resource group and deployment name as the input parameters. You can find the name of your Moodle deployment by viewing the deployment history in Azure portal. For more details about viewing the deployment history, see View deployment history with Azure Resource Manager.

 

For more information, see Moodle/Get-Install-Data in the Azure/Moodle GitHub repository.

 

Next steps

Get started by deploying your Moodle application on Azure using the provided templates. Then, if you have feedback or have any additional findings, just reach out to us at AskAzureDBforMySQL@service.microsoft.com, and we’ll be happy to incorporate it into our blog post.

 

Thank you!

 

Parikshit Savjani and Sai Kondapalli
Microsoft Azure Database for MySQL product group

24 Comments
Copper Contributor

.

Copper Contributor

Hi.

 

I see this template install or use image moodle. I want to know  where I can find the credentials to login.  Thks. 

Its auto generated using the following code

"moodleAdminPass": "[concat(toUpper('xl'), substring(uniqueString(resourceGroup().id, deployment().name), 6, 7),',1*8')]",
  "moodleDbName": "moodle",
Brass Contributor

@Parikshit SavjaniI am absolutely not experienced and looking for a good way to host moodle. I'd like to use Azure cause I work with Office365 a lot and need zo use Azure Active Directory already. But these deploying options seem really expensive to me. For the small deployment I get a cost estimate of Estimate total: $974.08. That is so much more than other hosting services offer for the complete service. I'm a getting something wrong here?

@ArneDD - Can you email us at Ask Azure DB for MySQL <AskAzureDBforMySQL@service.microsoft.com> with the number of users for which you are looking to provision Moodle environment, your preferred Azure region, some more background of your requirement (what do you plan to use it for and how long) and we can see how best we can assist to meet your goal 

Copper Contributor

@Parikshit Savjani I agree with @ArneDD that the mentioned templates are quite expensive - especially the "small" one. I did send an email with our requirements to the mentioned email address. 

When begining a project you want to start small and then scale as your demand grows. Starting with a 1.000 USD investment for a small moodle installation is not something you consider. We want to have the advantages of CLOUD services wich means start small and then grow... 

 

First, let me clarify on @ArneDD comment on the blog. We had a bug in our pricing calculator which quoted the price of the minimal configuration as $978 but it is actually $458 USD (depending on Azure region). However this estimation is based on the PAYG model. There are other cost optimization options which can bring your cost down signicantly to around ~$200 per month.. I have respond to your email. Let me know

 

Copper Contributor

hi i deployed large size installation in azure. moodle is working good. but i cant integration ldap extension. in moodle php info page, ldap must be see. i install php7.4-ldap in ubuntu. but it is not active moodle. and i cant coonect my ldap server to moodle.

Copper Contributor

I guess you'd better mind php7.4-ldap extension

Copper Contributor

PLease, how to use htmlLocalCopy, and what are the shell commands you mean for putting moodle in maint mode, do you mean moosh?

Copper Contributor

Hi,

 

We have tried to restore our moodle and theme folders over the top of this setup but the site doesn't seem to be updating. Is there a command or a refresh we need to run?

Copper Contributor

Hello,

When I install any of the distributions here, it is very successful, but by default it gives a domain name or dns, we want to move it to a special dns or domain name, how can we do that? For example, I want to change the default "lb-3fqpgf.westeurope.cloudapp.azure.com" domain name to "lms.abc.edu.tr".

Thank you for your interest.

Good luck with.

Regards.

Copper Contributor

@Parikshit Savjani I need some HELP!

 

I get that the changes need to be done via the Controller and i understand the script you need to execute to sync the controller with the public VM nodes. What is the best way to install themes, plugins etc. Do i use the controller and then sync and then refresh the VM's. Do i need to shut down any of the VMs?

 

After some changes i end up with Cache errors, see https://github.com/Azure/Moodle/issues/222

 

I can figure everything else out, but no idea why i get those cache errors?

 

Copper Contributor

Hi Parik**bleep**,

 

Thanks for posting this nice article, I have been searching about hosting Moodle on azure for the past 24 hours, I am asked to host Moodle on azure and make it available on web and mobile as well. 

 

I came a cross on your post but I have zero experience with azure that is why I wanted to ask you what is the different between your way and hosting Moodle through Bitnami? what are the benefit of each way? could you please explain?

 

I am also asking you if you could help me to host my Moodle on azure because as I said I don't have experience I need a step by step guideline with details, would you please help?

 

Best Regards, 

 

 

Copper Contributor

@Parikshit Savjani quick question, where can we find the password for the dbadmin to login onto MySQL?

@Christian Araujo - it is auto-generated and you would can see it in input parameter as shown in screenshot below. When you copy the MoodleCommon in clipboard and search for dbLoginPassword, you will see the password. 

 

 

dbpassword.png

 

Click on dbtemplate 

 

dbpassword1.png

 

Copy MoodleCommon to clipboard and paste it on notepad and search for dbLoginPassword to see the auto-generated password

Microsoft

There are a few questions about username and password here. Retrieval of this data is documented in Moodle/Get-Install-Data.md at master · Azure/Moodle (github.com)

Copper Contributor

How do we access the gluster nodes? What accounts/keys are they created with? The same question about the web VMSS nodes: Is there any way to log in to them to review the configuration?

Copper Contributor

@Parikshit Savjani quick question, I am starting a new setup of Moodle Small to Mid-Size, almost 1k of concurrent users. If the concurrent user pass to 2k is it hard tak to pass to Large size deployment (with high availability)? ...is it feasible?

Thank you for you advise

Copper Contributor

I am a novice trying to use Moodle (bitnami Image) on Azure. Installation has gone through smooth, but not able to work or access Moodle to see what it is. Any documentation available for a novice like me?

Hi @Constant2000 - Could you please expand on what help you need and you are trying to achieve? To get help on how to use Moodle, you may want on Moodle forums. 

Copper Contributor

Extreme Scale question....

@Parikshit Savjani Thanks for this valuable information.   We serve nearly 1 million student per year and up to 20,000 concurrent user per day.  Do you feel we could use your >5K configuration above with the highest Azure for MySQL 32 Cores, 320GB RAM memory optimized tier and that would be enough power?   Your comments above mentions 10K concurrent users, but my requirements are at least double that.

 

We're looking at Moodle's IOMAD Multi-tenancy to more easily manage 200 companies (school districts) in a single place, but we're concerned that there is no configuration powerful enough based on your above configs. If that is true, then we might be forced to have 200 different Moodle instances instead of a giant powerful redundant setup.

 

1. Do you have a more powerful setup suggestion then what you are describing above?

2. Any suggestion on how can load test such a giant setup?

 

Thoughts?

Hi @VFX_Pro - can u send us your query in an email at AskAzureDBforMySQL@service.microsoft.com and we can try to help you with our experts.

Copper Contributor

Hi,

 

I have tried to use this Large-size (with high availability) template and configure successfully, But as I am already using Moodle on azure, so when I migrate my Moodle code, database and Moodledata folder then every thing is working fine but site response is very Slow.

Is any recommendation for that how to migrate running Moodle code with this template. 

 

And we also planning to test Moodle 20000+ concurrent user, so now I am planning to use Maximum Deployment type template but again problem is same if I will try to migrate my running Moodle again facing same problem slow response. Can someone help me on this.

 

I request if any one have some suggestion and recommendation please help me on this.

 

Thanks

Aman Mishra

 

Version history
Last update:
‎Jul 18 2023 10:38 AM
Updated by: