DEV Community

ScaleGrid for ScaleGrid

Posted on • Edited on • Originally published at scalegrid.io

Five Tips for Better MongoDB Hosting on Azure

The Azure cloud computing platform has gone through a dizzying array of improvements over the past couple of years, scarcely resembling the original platform that Microsoft started with back in 2010.  ScaleGrid was one of the earliest MongoDB hosting platforms to support Azure and we have continued to evolve our offering as Azure evolves.

Whether you've been using Azure for a while or just starting to use Azure for MongoDB hosting, here are some architecture design patterns you should consider to ensure that you're leveraging the Azure platform for the best MongoDB hosting experience.

  1. Azure Resource Manager (ARM) Platform

    Leverage the power of the new Azure Resource Manager (ARM) platform. If you're still on the Azure Classic platform, the time to move is now! There are several benefits to moving to the new ARM platform include leveraging managed disks, virtual networks, and reserved instances. All the benefits are detailed in the Benefits of migrating IaaS to Azure Resource Manager blog post.

  2. Azure Virtual Networks & Network Security Groups

    Databases are best deployed in private subnets that are not exposed to the internet. Azure allows you to create your own Virtual Network (VNET) and deploy your database servers to specific subnets. You can also handle access control by creating Network Security Group (NSG) rules, and assign a public IP to your database server (only) if you need to make it accessible over the internet. As part of our Bring Your Own Cloud model, we allow our customers to deploy their MongoDB clusters in their own VNET to leverage the advanced VNET and NSG security controls.

  3. Azure Availability Set & Availability Zones

    Availability sets are essential to distribute the nodes of your cluster across different hardware. This way, a single hardware failure does not impact all of your nodes. Our recommendation is to create an availability set per replica. Azure has also recently introduced Availability zones to protect you from datacenter-level outages. You can distribute your replicas across availability zones for 99.99% uptime.

  4. Azure Instance Types

    Choosing the right Azure instance type for your MongoDB load is very important - not all the instance types are a good fit for MongoDB. In general, you should be looking at 'Memory optimized' instance types or the 'Storage optimized' instance types.

    The latest Ev3 series of memory-optimized instances are typically a great starting point for most MongoDB workloads. If you need more CPU than provided by the E2 v3, you can consider the 'General purpose' Dv3 instance types.

    The 'Burst' mode instances - 'B1S, B1MS, B2MS' are typically a good fit for small workloads, dev/test environments, etc. As your data gets larger, the 'Storage optimized' L4 series with Azure local SSD disks are a great fit - more details in the Azure Disk section below. In general, the right instance type depends on your workload, so it's important to iterate and load test the various instance types with your workload.

  5. Azure Disks

    Azure offers a variety of disk types to handle different workloads:
    • Legacy Disks (Standard & Premium)

      For the purposes of this discussion, we are not going to consider the Legacy Azure disks.  If you're using legacy disks, you should consider moving to managed disks.
    • Managed Disks (Standard & Premium)

      Azure Managed Disks greatly simplify the management of your compute disks on Azure.  They offer several advantages over legacy disks:

      • No need to worry about storage accounts.
      • No need to worry about storage account size and performance limits.
      • Easy snapshots and creating new disks from snapshots.
      • Easily convert from standard to premium and vice versa.
      • Leverage enhanced availability sets to apply to your disks.

      You can find the full details on the differences between Managed disks and Legacy disks in the Azure documentation.

      Premium Managed Disks also offer different IOPS gaurantees depending on the size of the disk. For production MongoDB clusters, we would highly recommend Premium Managed Disks while for dev/test environments, Standard Managed Disks are a good fit.
    • Local SSD Disks

      Azure 'Storage optimized' instances types provide large local SSD disks which offer the best throughput in Azure. This is a great fit for large clusters that need a lot of disk input/output (I/O). Our Azure High Performance clusters for MongoDB use the L-series instances. However, local SSD disks are 'ephemeral' - when  you stop the instance, the data goes away. So, it's important to take great care when using local disks. Our recommendation is to use one replica that's on Managed Premium Disks to ensure the safety of the data.

  6. I know we promised 5 tips, but here is an extra one for the road:
  7. Leverage Azure Reserved Instances

    Azure now supports Reserved Instances (RI's) a.k.a AWS. You can purchase Azure Reserved Instances for one year or three year periods in advanced and greatly reduce your MongoDB hosting costs up to 82%.

Top comments (0)