Five Tips for Better MongoDB Hosting on Azure
Tags: mongodb, azure, security, cloud
Published: 2018-05-14 17:40:04

---
title: Five Tips for Better MongoDB Hosting on Azure
published: true
description: Whether you’ve been using Azure for a while or just getting started, here are some architecture design patterns you should consider to ensure the best MongoDB hosting experience.
tags: MongoDB, Azure, Security, Cloud,
canonical_url: https://scalegrid.io/blog/five-tips-for-better-mongodb-hosting-on-azure/
---
<link rel="canonical" href="https://scalegrid.io/blog/five-tips-for-better-mongodb-hosting-on-azure/" />

<img src="https://thepracticaldev.s3.amazonaws.com/i/8vru4wtcqd5o0m08m0o8.jpg">
<p style="text-align: justify;">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 <a title="MongoDB hosting platform" href="http://scalegrid.io" target="_blank">MongoDB hosting platforms</a> to support Azure and we have continued to evolve our offering as Azure evolves.</p>
<p style="text-align: justify;">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.</p>

<ol>

	<li class="has-heading">
<h2 class="heading">Azure Resource Manager (ARM) Platform</h2>
<p style="text-align: justify;">Leverage the power of the new <a title="Azure Resource Manager" href="https://azure.microsoft.com/en-us/features/resource-manager/" target="_blank">Azure Resource Manager</a> (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 <a title="Benefits of migrating IaaS to Azure Resource Manager" href="https://azure.microsoft.com/en-us/blog/migrate-iaas-to-azure-resource-manager/" target="_blank">Benefits of migrating IaaS to Azure Resource Manager</a> blog post.</p>
</li>
	<li class="has-heading">
<h2 class="heading">Azure Virtual Networks &amp; Network Security Groups</h2>
<p style="text-align: justify;">Databases are best deployed in private subnets that are not exposed to the internet. Azure allows you to create your own <a title="Azure Virtual Network (VNET)" href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview" target="_blank">Virtual Network </a>(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 <a title="Bring Your Own Cloud - Azure MongoDB Hosting" href="https://scalegrid.io/blog/bring-your-own-azure-account-for-mongodb-redis-hosting/" target="_blank">Bring Your Own Cloud</a> model, we allow our customers to deploy their MongoDB clusters in their own VNET to leverage the advanced VNET and NSG security controls.</p>
</li>
	<li class="has-heading">
<h2 class="heading">Azure Availability Set &amp; Availability Zones</h2>
<p style="text-align: justify;"><a title="Azure Availability Sets" href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-availability-sets" target="_blank">Availability sets</a> 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 <a title="Azure Availability Zones" href="https://docs.microsoft.com/en-us/azure/availability-zones/az-overview" target="_blank">Availability zones</a> to protect you from datacenter-level outages. You can distribute your replicas across availability zones for 99.99% uptime.</p>

</li>
	<li class="has-heading">
<h2 class="heading">Azure Instance Types</h2>
<p style="text-align: justify;">Choosing the right <a title="Azure Instance Types" href="https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/" target="_blank">Azure instance type</a> 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.</p>
<p style="text-align: justify;">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.</p>
<p style="text-align: justify;">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 <a title="Load Tests - How to Benchmark MongoDB with YCSB" href="https://scalegrid.io/blog/how-to-benchmark-mongodb-with-ycsb/" target="_blank">load test</a> the various instance types with your workload.</p>
</li>
	<li class="has-heading">
<h2 class="heading">Azure Disks</h2>
Azure offers a variety of disk types to handle different workloads:
<ul>
	<li>
<h3>Legacy Disks (Standard &amp; Premium)</h3>
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.</li>
	<li>
<h3>Managed Disks (Standard &amp; Premium)</h3>
<p style="text-align: justify;"><a title="Azure Managed Disks" href="https://azure.microsoft.com/en-us/services/managed-disks/" target="_blank">Azure Managed Disks</a> greatly simplify the management of your compute disks on Azure.  They offer several advantages over legacy disks:</p>

<ul>
	<li>No need to worry about storage accounts.</li>
	<li>No need to worry about storage account size and performance limits.</li>
	<li>Easy snapshots and creating new disks from snapshots.</li>
	<li>Easily convert from standard to premium and vice versa.</li>
	<li>Leverage enhanced availability sets to apply to your disks.</li>
</ul>
<p style="text-align: justify;">You can find the full details on the differences between Managed disks and Legacy disks in the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/managed-disks-overview">Azure documentation</a>.</p>

<div style="color: #222222; text-align: justify;"><a title="Azure Premium Managed Disks" href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/premium-storage" target="_blank">Premium Managed Disks</a> 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.</div></li>
	<li>
<h3 style="text-align: justify;">Local SSD Disks</h3>
<p style="text-align: justify;">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 <a title="Azure High Performance MongoDB Hosting" href="https://scalegrid.io/pricing.html" target="_blank">Azure High Performance</a> clusters for MongoDB use the <a title="Azure L-Series" href="https://azure.microsoft.com/en-us/pricing/details/virtual-machines/series/" target="_blank">L-series</a> 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.</p>
</li>
</ul>
</li>

I know we promised 5 tips, but here is an extra one for the road:

	<li class="has-heading">
<h2 class="heading">Leverage Azure Reserved Instances</h2>
<p style="text-align: justify;padding-bottom:20px;">Azure now supports <a title="Azure Reserved Instances" href="https://azure.microsoft.com/en-us/pricing/reserved-vm-instances/" target="_blank">Reserved Instances</a> (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%.</p>
</li>
</ol>