Azure database

MongoDB on Azure: Managed Service vs. Self-Managed

[Azure, Cloud Volumes ONTAP, Database, Analytics, Advanced, 8 minute read, Azure database]

MongoDB on Azure: Managed Service vs. Self-Managed Deployment

The MongoDB database provides organizations an opportunity to evolve and store data without being confined to the initial underlying data model. As part of an Azure database deployment, MongoDB can add its capabilities to the Microsoft cloud’s scalability and services. These capabilities can make MongoDB usage a key part of your Azure big data workloads.

This post will introduce you to the two major deployment options for using MongoDB on Azure, deploying with a managed service or running it on self-managed compute instances, and cover all of the following:

NoSQL and MongoDB at a Glance

A NoSQL database is everything an SQL database is not. It is a non-tabular storage that allows you to store data in document, key-value, wide-column, or graph. This non-tabular nature of NoSQL makes it easy to scale horizontally across distributed nodes unlike SQL databases which scale primarily vertically.

Founded in 2007 and a NoSQL database, MongoDB is an open-source database built to address the scalability needs of 21st century applications.

Unlike relational databases where data is stored in tables following a predefined schema, MongoDB typically stores data as a JSON object allowing for the flexibility to evolve data schema without being restricted to a predefined data schema.

Some common use cases for MongoDB include:

  • Big Data applications
  • Data analytics
  • Mobile development
  • Internet of Things (IoT)
  • Real-time analytics
  • Geospatial applications
  • Payment systems

Does Azure Have Support for MongoDB?

There is support for MongoDB on a wide range of cloud providers, Azure included. You can use MongoDB on Azure regardless of your system's architecture. Whether you're already operating on Azure, looking to switch, or using a different cloud service for your application, when you combine MongoDB with Azure, you get the added benefits Azure cloud computing has to offer.

How Do I Run MongoDB on Azure?

There are two ways to use MongoDB on Azure:

  • With the fully managed-service options: Azure Cosmos DB or MongoDB Atlas.
  • Self-managed option using MongoDB on raw Azure VMs.

For the rest of this post, we’ll explore the pros and cons of the two deployment options and how to migrate your existing MongoDB cluster to Azure.

Azure: Managed Deployment Options for MongoDB

The managed deployment option lifts the burden of installation and configuration from enterprises, allowing them to focus on their business domain. There are two alternatives when it comes to managed deployment options. You can either use Azure managed option Cosmos DB or a third-party managed option through MongoDB Atlas.

Azure Cosmos DB: MongoDB Managed Deployment Options

Microsoft Azure Cosmos DB is a fully managed, distributed, scalable schema-agnostic, multi-model NoSQL database. It provides flexible access to data using the API of choices such as SQL API (JSON), MongoDB API (BSON, key-value), and Gremlin API (graph), Table API (key-value) and Cassandra API (columnar), which are all essentially supported. You can integrate Azure Cosmos DB using your existing MongoDB clients.

Is Azure Cosmos DB the Same as MongoDB?

Cosmos DB is not the same as MongoDB. There is a connection though: Azure Cosmos DB was implemented based on a wire protocol that allows clients to work on Cosmos DB as comfortably as if it was an actual MongoDB database. That gives existing MongoDB users a familiar interface. However, there are key differences and before shopping for a deployment option, you should familiarize yourself with the differences and limitations.

Azure CosmosDB Managed Service for MongoDB: Pros and Cons

While Azure Cosmos DB has some limitations, it also has some strengths that made it suitable for a wide range of use cases. In this section we’ll take a look at them both.

Pros

  • MongoDB Compatibility: Cosmos DB is compatible with the latest MongoDB API versions: 3.2, 3.6 and 4.0.
  • Scalability: The service allows you to manually scale or autoscale in response to your application needs up to a maximum of 1,000,000 Request Unit Per Sec (RU/s) by default.
  • Low Latency: Azure Cosmos DB is globally distributed and offers an ultra-low, 10 millisecond latency for read operations at 99% for any consistency level you choose.
  • Availability: Azure Cosmos DB has an SLA of 99.999-percent availability.

Cons

  • Sort support: Azure Cosmos DB does not support sort on multiple fields when performing “findOneAndUpdateOperation”.
  • Cosmos DB does not support manual replication
  • Write retry limitation: You can’t retry writes in Cosmos DB at the time of writing this post.
  • Manual sharding support: Cosmos DB doesn’t have current support for manual sharding commands. Server-side sharding is automatic.
  • You can’t use the server-side sessions command with Azure Cosmos DB.
  • No current definitions for user or RBAC: No support to restrict access to specific users and roles within your organization.
  • Indexing limitations: 2d Index command and case-insensitive index are not supported.
  • Past MongoDB Compatibility: CosmoDB is not compatible with all MongoDB versions, especially the older versions of MongoDB.
  • No control over resource management: Resources are managed by the service provider, meaning they may not be ideally placed for your deployment.

There is another consideration to keep in mind between Cosmos DB and MongoDB: Azure pricing for Cosmos DB is billed per hour. You’re charged based on your provisioned throughput. You can use Azure price calculator to estimate your cost.

Third-Party Managed Option: MongoDB Atlas

If you like to use a managed MongoDB database on Azure but not a MongoDB-compatible option like Cosmos DB, there is another option: MongoDB Atlas, the fully managed database-as-a-service platform provided by MongoDB that allows you to use MongoDB across the major cloud providers including Azure.

Running MongoDB on Azure VMs: The Self-Managed Option

Businesses choose self-managed options when they want full control over the database and the compute resources their cluster runs. Azure VMs allow them to do so.

The easiest way to deploy MongoDB on Azure VM is through Azure Resource Manager (ARM) template. ARM templates are JSON files that contain the information on how your infrastructure is defined and how it should be configured. To deploy MongoDB on Azure, you can either define an ARM template or use existing MongoDB ARM templates.

Various applications have different specifications. An application's requirement could require you to use a self-managed alternative. As a result, it's important to weigh the benefits and drawbacks. Let’s take a look at them each.

Pros

  • Full control: You have the flexibility to define your database configuration while enjoying all features supported on Azure. For example, using self-managed MongoDB, you would have full MongoDB API support.
  • Geographical independence: You have full control on where to put your data.
  • Lower cost: Without the added premium of a managed service.
  • Easy Migration: Refactoring an existing application/architecture is less expensive.
  • Avoid Azure lock-in: With the self-managed option, you can avoid being bound to a single vendor.

Cons

  • Technical complexity: Requires technical know-how to handle the installation, tuning, monitoring and administration.
  • Time investment: Time-consuming since you’re responsible for setup, management, scaling and maintenance.
  • Domain expertise: Need a dedicated team of highly skilled database engineers.

Migrating MongoDB to Azure

There are several ways to migrate MongoDB to Azure:

  • Azure Database Migration Service (Azure DMS) provides a quick, easy, and fully automated way to migrate SQL and NoSQL databases to the cloud without code changes for both one-time and continuous synchronization migrations.
  • Atlas Live Migration Service makes it possible to migrate data from an existing environment to MongoDB Atlas with minimal impact on your application.
  • Command-line utilities such as MongoDB’s mongodump and mongorestore are command-line tools that work with BSON data dumps for importing and exporting a database.

The Third Path: MongoDB Deployment in Azure with Cloud Volumes ONTAP

With Cloud Volumes ONTAP, there is a way to combine the advantages of both deployment options and get the best of both worlds.

Cloud Volumes ONTAP is a data management platform for Azure, AWS, and Google Cloud that enables enterprises to easily deploy MongoDB databases and scale their applications quickly without compromising performance. As a data management layer built on native Azure compute and storage, with Cloud Volumes ONTAP you combine the configurability and control of the managed storage option with feature benefits of a managed service.

With Cloud Volumes ONTAP, your MongoDB deployment on Azure:

  • Avoids limits on scalability, configuration, or instance type
  • Prevents getting locked to Azure
  • Gives you full control over resource usage and placement
  • Spans beyond Azure, with data mobility between clouds and on-prem

With its centralized management via NetApp Cloud Manager, you gain visibility over all of your storage volumes no matter which cloud they’re running in and the ability to carry out IAC operations through RESTful API calls.

This goes beyond the limitations of a managed service, while providing features that building and managing your own MongoDB deployment on virtual machines can’t match: 

  • A dual-node high availability configuration that provides RPO=0 and RTO < 60 seconds
  • Point-in-time data protection via NetApp Snapshot™ copies
  • Full data mobility, replication, and sync capabilities with SnapMirror®
  • Instant data volume cloning with FlexClone® that only charge for the delta
  • Storage efficiency features such as data deduplication and automatic tiering of infrequently used data to object storage reduce total storage costs for a MongoDB database by as much as 70%.

New call-to-action

Yifat Perry, Product Marketing Lead

Product Marketing Lead

-