Azure Cosmos DB API for MongoDB

APPLIES TO: Azure Cosmos DB API for MongoDB

The Azure Cosmos DB API for MongoDB makes it easy to use Cosmos DB as if it were a MongoDB database. You can leverage your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB account's connection string.

Why choose the API for MongoDB

The API for MongoDB has numerous added benefits of being built on Azure Cosmos DB when compared to service offerings such as MongoDB Atlas:

  • Instantaneous scalability: By enabling the Autoscale feature, your database can scale up/down with zero warmup period.
  • Automatic and transparent sharding: The API for MongoDB manages all of the infrastructure for you. This includes sharding and the number of shards, unlike other MongoDB offerings such as MongoDB Atlas, which require your to specify and manage sharding to horizontally scale. This gives you more time to focus on developing applications for your users.
  • Five 9's of availability: 99.999% availability is easily configurable to ensure your data is always there for you.
  • Cost efficient, granular, unlimited scalability: Sharded collections can scale to any size, unlike other MongoDB service offerings. API for MongoDB users are running databases with over 600TB of storage today. Scaling is done in a cost-efficient manner, since unlike other MongoDB service offering, the Cosmos DB platform can scale in increments as small as 1/100th of a VM due to economies of scale and resource governance.
  • Serverless deployments: Unlike MongoDB Atlas, the API for MongoDB is a cloud native database that offers a serverless capacity mode. With Serverless, you are only charged per operation, and don't pay for the database when you don't use it.
  • Free Tier: With Azure Cosmos DB free tier, you'll get the first 1000 RU/s and 25 GB of storage in your account for free forever, applied at the account level.
  • Upgrades take seconds: All API versions are contained within one codebase, making version changes as simple as flipping a switch, with zero downtime.
  • Real time analytics (HTAP) at any scale: The API for MongoDB offers the ability to run complex analytical queries for use cases such as business intelligence against your database data in real time with no impact to your database. This is fast and cheap, due to the cloud native analytical columnar store being utilized, with no ETL pipelines. Learn more about the Azure Synapse Link.

Note

You can use Azure Cosmos DB API for MongoDB for free with the free Tier!. With Azure Cosmos DB free tier, you'll get the first 1000 RU/s and 25 GB of storage in your account for free, applied at the account level.

How the API works

Azure Cosmos DB API for MongoDB implements the wire protocol for MongoDB. This implementation allows transparent compatibility with native MongoDB client SDKs, drivers, and tools. Azure Cosmos DB does not host the MongoDB database engine. Any MongoDB client driver compatible with the API version you are using should be able to connect, with no special configuration.

MongoDB feature compatibility:

Azure Cosmos DB API for MongoDB is compatible with the following MongoDB server versions:

All the API for MongoDB versions run on the same codebase, making upgrades a simple task that can be completed in seconds with zero downtime. Azure Cosmos DB simply flips a few feature flags to go from one version to another. The feature flags also enable continued support for older API versions such as 3.2 and 3.6. You can choose the server version that works best for you.

Azure Cosmos DB's API for MongoDB

What you need to know to get started

  • You are not billed for virtual machines in a cluster. Pricing is based on throughput in request units (RUs) configured on a per database or per collection basis. The first 1000 RUs per second are free with Free Tier.

  • There are three ways to deploy Azure Cosmos DB API for MongoDB:

    • Provisioned throughput: Set a RU/sec number and change it manually. This model best fits consistent workloads.
    • Autoscale: Set an upper bound on the throughput you need. Throughput instantly scales to match your needs. This model best fits workloads that change frequently and optimizes their costs.
    • Serverless (preview): Only pay for the throughput you use, period. This model best fits dev/test workloads.
  • Sharded cluster performance is dependent on the shard key you choose when creating a collection. Choose a shard key carefully to ensure that your data is evenly distributed across shards.

Quickstart

Next steps

Note: This article describes a feature of Azure Cosmos DB that provides wire protocol compatibility with MongoDB databases. Microsoft does not run MongoDB databases to provide this service. Azure Cosmos DB is not affiliated with MongoDB, Inc.