AnnouncementIntroducing MongoDB 8.0, the fastest MongoDB ever! Read more >>Introducing MongoDB 8.0, the fastest MongoDB ever! >>

Comparing Microsoft Cosmos DB With MongoDB

Cosmos DB is a proprietary NoSQL database offered by Microsoft as a managed service on its Azure cloud platform. Originally launched as DocumentDB in 2015, the service got very little developer adoption and was relaunched as Cosmos DB in 2017. In an attempt to gain market traction, Microsoft began offering developers several APIs to work with data, including an imitation of the MongoDB API.

Cosmos DB is positioned as providing a globally scalable, multi-model database supporting operational applications. It borrows many concepts from MongoDB, but falls short in compatibility and functionality. For example, you can only query data using a single model. If you provision a container with the SQL API, you cannot query it with the Cosmos DB emulation API. Cosmos DB also does not support time-series data. MongoDB, on the other hand, lets you run key-value, graph, and SQL queries against the same data. And, with MongoDB 5.0, you can build and run applications with support for specific time-series data storage and query patterns.

Both MongoDB (through MongoDB Atlas) and Cosmos DB are available as fully managed, global database services on Azure. However, MongoDB provides much richer functionality to support a broader range of use cases and, crucially, more deployment flexibility, eliminating lock-in to any one cloud provider, especially with multi-cloud clusters. Cosmos DB can only be run as a managed service on Azure, requiring a full-scale migration if users ever want to run on another cloud provider.

The chart below shows how the different options stack up.*

*As of November 2023

MongoDBMicrosoft Cosmos DB Emulation API
Choice of cloud providersNo
Integrated text search, geospatial processing

Limited

Some support for geospatial data, but with limited indexing

Supports all MongoDB features with full application compatibility

No

Claims compatibility with v4.2 API, actually closer to 3.6

No MongoDB server-side code

Fails over 67% of compatibility tests

Access to the latest MongoDB version

No

Claims compatibility with v4.2 API; many features not supported, some with significant limitations

Free tier

Limited

Just for the first 400 RU/s. Not sandboxed, so no way to avoid cost if usage increases beyond the 400RU/s limit

Live migrationOnly for eligible accounts
Choice of instance configuration

No

Configuration based on provisioned throughput. No way to independently select underlying hardware configurations

Support for MongoDB multi-document ACID transactions

Limited

Multi-document transactions are supported only within a single, unsharded collection; fails almost all of MongoDB's transaction tests

JSON data type support

BSON

Some data types have restrictions, including the inability to modify them once set

Maximum document size2 MB
JSON schema for data governance controls

No

All schema controls must be written in the app tier

Integrated text search and graph queriesNo integrated text search
Integrated querying of data in cloud object storageNo

Online archive
Automatically tier data out from database to cloud object storage

No

Blend data with joins and unions for analytics queries

No

Automatic performance recommendations

No

Replica set configuration

3 data-bearing nodes
Automatic sharding support

Yes

However, no support to refine the chosen shard key, forcing a full database migration should the shard key need to change in any way.

Hedged reads
Queries submitted to multiple replicas for consistent low latency

No

Pause and resume clusters

No
Data explorerYes
SQL-based connectivity

Yes

Native SQL queries require separate instance of Cosmos DB with SQL API; no way to run SQL queries directly against a Cosmos DB instance using the MongoDB imitation API

Power BI and Qlik Sense allow for SQL analytics queries

Native data visualization without 3rd party BI toolsNo
Database supported in on-premise and hybrid deploymentsNo
Embeddable database with sync for mobile devicesNo
MongoDB
Choice of cloud providers

Yes

AWS, Azure & Google Cloud, including multi-cloud clusters spanning all three cloud platforms

Integrated text search, geospatial processing

Yes

Supports all MongoDB features with full application compatibility

Yes

Runs native MongoDB

Access to the latest MongoDB version

Yes

Run the latest release of MongoDB or any supported previous versions

Free tier

Yes

Storage: 512 MB; RAM: Variable

Live migrationYes
Choice of instance configuration

Yes

Multiple instance sizes and classes

Support for MongoDB multi-document ACID transactions Yes
JSON data type support

BSON (Binary JSON)

Regular JSON + longs, doubles, floats, decimal, dates, and times

Maximum document size

16 MB

JSON schema for data governance controls

Yes

Integrated text search and graph queries

Yes

MongoDB aggregation pipeline and Atlas Search

Integrated querying of data in cloud object storage

Online archive
Automatically tier data out from database to cloud object storage

Blend data with joins and unions for analytics queries

Yes

Automatic performance recommendations

Yes

Performance Advisor with schema and index recommendations

Replica set configuration

Up to 50 replicas by default; expandable upon request

All replicas configured as data-bearing nodes

Automatic sharding support

Yes

Scale writes horizontally across multiple nodes. Store multiple TB of data on a single shard.

Ability to refine shard key as application requirements evolve.

Hedged reads
Queries submitted to multiple replicas for consistent low latency

Yes

Pause and resume clusters

Yes
Data explorer

Yes

Directly in Atlas UI, or via MongoDB Compass

SQL-based connectivity
Native data visualization without 3rd party BI tools
Database supported in on-premise and hybrid deployments
Embeddable database with sync for mobile devices
Microsoft Cosmos DB Emulation API
Choice of cloud providersNo
Integrated text search, geospatial processing

Limited

Some support for geospatial data, but with limited indexing

Supports all MongoDB features with full application compatibility

No

Claims compatibility with v4.2 API, actually closer to 3.6

No MongoDB server-side code

Fails over 67% of compatibility tests

Access to the latest MongoDB version

No

Claims compatibility with v4.2 API; many features not supported, some with significant limitations

Free tier

Limited

Just for the first 400 RU/s. Not sandboxed, so no way to avoid cost if usage increases beyond the 400RU/s limit

Live migrationOnly for eligible accounts
Choice of instance configuration

No

Configuration based on provisioned throughput. No way to independently select underlying hardware configurations

Support for MongoDB multi-document ACID transactions

Limited

Multi-document transactions are supported only within a single, unsharded collection; fails almost all of MongoDB's transaction tests

JSON data type support

BSON

Some data types have restrictions, including the inability to modify them once set

Maximum document size2 MB
JSON schema for data governance controls

No

All schema controls must be written in the app tier

Integrated text search and graph queriesNo integrated text search
Integrated querying of data in cloud object storageNo

Online archive
Automatically tier data out from database to cloud object storage

No

Blend data with joins and unions for analytics queries

No

Automatic performance recommendations

No

Replica set configuration

3 data-bearing nodes
Automatic sharding support

Yes

However, no support to refine the chosen shard key, forcing a full database migration should the shard key need to change in any way.

Hedged reads
Queries submitted to multiple replicas for consistent low latency

No

Pause and resume clusters

No
Data explorerYes
SQL-based connectivity

Yes

Native SQL queries require separate instance of Cosmos DB with SQL API; no way to run SQL queries directly against a Cosmos DB instance using the MongoDB imitation API

Power BI and Qlik Sense allow for SQL analytics queries

Native data visualization without 3rd party BI toolsNo
Database supported in on-premise and hybrid deploymentsNo
Embeddable database with sync for mobile devicesNo

Global Clusters

MongoDBMicrosoft Cosmos DB Emulation API
Multi-cloud deployment

No

Cosmos users are limited to Azure availability zones only

Active-active clusters supporting global writes

Low-latency writes from anywhere in the world

Yes

Risk of data loss due to conflict resolution. Reads can be eventually consistent (returning stale or deleted data)

Cross-region replication Distribute data around the world for multi-region fault tolerance and local reads

Yes

Reads can be eventually consistent (returning stale or deleted data)

MongoDB
Multi-cloud deployment

Yes

Deploy across 110+ AWS, Azure, and Google Cloud regions

Active-active clusters supporting global writes

Low-latency writes from anywhere in the world

Yes

Cross-region replication Distribute data around the world for multi-region fault tolerance and local reads

Yes
Microsoft Cosmos DB Emulation API
Multi-cloud deployment

No

Cosmos users are limited to Azure availability zones only

Active-active clusters supporting global writes

Low-latency writes from anywhere in the world

Yes

Risk of data loss due to conflict resolution. Reads can be eventually consistent (returning stale or deleted data)

Cross-region replication Distribute data around the world for multi-region fault tolerance and local reads

Yes

Reads can be eventually consistent (returning stale or deleted data)

Monitoring and Disaster Recovery

MongoDBMicrosoft Cosmos DB Emulation API
Automatic scaling of compute and storage

Yes

50% upcharge for autoscaling, can only scale within a certain tier

Monitoring of database health with automated alerting

Partial

Only a limited number of account-level metrics are exposed

Backup snapshots with on-demand Point in Time restoreYes
Queryable backupsNo
Automated & consistent snapshots of sharded clustersNo
MongoDB
Automatic scaling of compute and storageYes
Monitoring of database health with automated alerting

Yes

MongoDB Atlas UI & support for APM platforms (i.e., New Relic)

Backup snapshots with on-demand Point in Time restoreYes
Queryable backupsYes
Automated & consistent snapshots of sharded clustersYes
Microsoft Cosmos DB Emulation API
Automatic scaling of compute and storage

Yes

50% upcharge for autoscaling, can only scale within a certain tier

Monitoring of database health with automated alerting

Partial

Only a limited number of account-level metrics are exposed

Backup snapshots with on-demand Point in Time restoreYes
Queryable backupsNo
Automated & consistent snapshots of sharded clustersNo

Security Controls

MongoDBMicrosoft Cosmos DB Emulation API
Granular role-based access control

Limited

Coarse-grained roles only

AWS VPC PeeringN/A
Encryption of data in-flightYes
Encryption of data at-restYes

Client-side field level encryption
Encryption of data in-use. Data not readable by service provider

No

Queryable Encryption
Data encrypted on the client side can be queried without decryption.

No
LDAP IntegrationYes

Database-level auditing
Track DDL, DML, DCL operations

Yes
Bring your own KMS

No

Azure key vault only

MongoDB
Granular role-based access controlYes
AWS VPC PeeringYes
Encryption of data in-flight

Yes

TLS/SSL as standard

Encryption of data at-restYes

Client-side field level encryption
Encryption of data in-use. Data not readable by service provider

Yes

Queryable Encryption
Data encrypted on the client side can be queried without decryption.

Yes
LDAP IntegrationYes

Database-level auditing
Track DDL, DML, DCL operations

Yes
Bring your own KMSYes
Microsoft Cosmos DB Emulation API
Granular role-based access control

Limited

Coarse-grained roles only

AWS VPC PeeringN/A
Encryption of data in-flightYes
Encryption of data at-restYes

Client-side field level encryption
Encryption of data in-use. Data not readable by service provider

No

Queryable Encryption
Data encrypted on the client side can be queried without decryption.

No
LDAP IntegrationYes

Database-level auditing
Track DDL, DML, DCL operations

Yes
Bring your own KMS

No

Azure key vault only

Support and Services

MongoDBMicrosoft Cosmos DB Emulation API
Database support delivered directly by MongoDB engineers

No

Consulting services from engineers with multiple years of MongoDB expertiseNo
MongoDB
Database support delivered directly by MongoDB engineers

Yes

Available with an optional support contract

Consulting services from engineers with multiple years of MongoDB expertise

Yes

MongoDB Consulting Services

Microsoft Cosmos DB Emulation API
Database support delivered directly by MongoDB engineers

No

Consulting services from engineers with multiple years of MongoDB expertiseNo

Get started with MongoDB Atlas today