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.*
MongoDB | Microsoft Cosmos DB Emulation API | |
---|---|---|
Choice of cloud providers | Yes AWS, Azure & Google Cloud, including multi-cloud clusters spanning all three cloud platforms | No |
Integrated text search, geospatial processing | Yes | Limited Some support for geospatial data, but with limited indexing |
Supports all MongoDB features with full application compatibility | Yes Runs native MongoDB | 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 | Yes Run the latest release of MongoDB or any supported previous versions | No Claims compatibility with v4.2 API; many features not supported, some with significant limitations |
Free tier | Yes Storage: 512 MB; RAM: Variable | 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 migration | Yes | Only for eligible accounts |
Choice of instance configuration | Yes Multiple instance sizes and classes | No Configuration based on provisioned throughput. No way to independently select underlying hardware configurations |
Support for MongoDB multi-document ACID transactions | Yes | 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 (Binary JSON) Regular JSON + longs, doubles, floats, decimal, dates, and times | BSON Some data types have restrictions, including the inability to modify them once set |
Maximum document size | 16 MB | 2 MB |
JSON schema for data governance controls | Yes | No All schema controls must be written in the app tier |
Integrated text search and graph queries | Yes MongoDB aggregation pipeline and Atlas Search | No integrated text search |
Integrated querying of data in cloud object storage | No | |
Online archive | No | |
Blend data with joins and unions for analytics queries | Yes | No |
Automatic performance recommendations | Yes Performance Advisor with schema and index recommendations | No |
Replica set configuration | Up to 50 replicas by default; expandable upon request All replicas configured as data-bearing nodes | 3 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. | 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 | Yes | No |
Pause and resume clusters | Yes | No |
Data explorer | Yes Directly in Atlas UI, or via MongoDB Compass | Yes |
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 tools | No | |
Database supported in on-premise and hybrid deployments | No | |
Embeddable database with sync for mobile devices | No |
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 migration | Yes |
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 | |
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 | 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 providers | No |
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 migration | Only 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 size | 2 MB |
JSON schema for data governance controls | No All schema controls must be written in the app tier |
Integrated text search and graph queries | No integrated text search |
Integrated querying of data in cloud object storage | No |
Online archive | 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 | No |
Pause and resume clusters | No |
Data explorer | Yes |
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 tools | No |
Database supported in on-premise and hybrid deployments | No |
Embeddable database with sync for mobile devices | No |
MongoDB | Microsoft Cosmos DB Emulation API | |
---|---|---|
Multi-cloud deployment | Yes Deploy across 110+ AWS, Azure, and Google Cloud regions | 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 | 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 | 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) |
MongoDB | Microsoft Cosmos DB Emulation API | |
---|---|---|
Automatic scaling of compute and storage | Yes | Yes 50% upcharge for autoscaling, can only scale within a certain tier |
Monitoring of database health with automated alerting | Yes MongoDB Atlas UI & support for APM platforms (i.e., New Relic) | Partial Only a limited number of account-level metrics are exposed |
Backup snapshots with on-demand Point in Time restore | Yes | Yes |
Queryable backups | Yes | No |
Automated & consistent snapshots of sharded clusters | Yes | No |
MongoDB | |
---|---|
Automatic scaling of compute and storage | Yes |
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 restore | Yes |
Queryable backups | Yes |
Automated & consistent snapshots of sharded clusters | Yes |
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 restore | Yes |
Queryable backups | No |
Automated & consistent snapshots of sharded clusters | No |
MongoDB | Microsoft Cosmos DB Emulation API | |
---|---|---|
Granular role-based access control | Yes | Limited Coarse-grained roles only |
AWS VPC Peering | Yes | N/A |
Encryption of data in-flight | Yes TLS/SSL as standard | Yes |
Encryption of data at-rest | Yes | Yes |
Client-side field level encryption | Yes | No |
Queryable Encryption | Yes | No |
LDAP Integration | Yes | Yes |
Database-level auditing | Yes | Yes |
Bring your own KMS | Yes | No Azure key vault only |
MongoDB | |
---|---|
Granular role-based access control | Yes |
AWS VPC Peering | Yes |
Encryption of data in-flight | Yes TLS/SSL as standard |
Encryption of data at-rest | Yes |
Client-side field level encryption | Yes |
Queryable Encryption | Yes |
LDAP Integration | Yes |
Database-level auditing | Yes |
Bring your own KMS | Yes |
Microsoft Cosmos DB Emulation API | |
---|---|
Granular role-based access control | Limited Coarse-grained roles only |
AWS VPC Peering | N/A |
Encryption of data in-flight | Yes |
Encryption of data at-rest | Yes |
Client-side field level encryption | No |
Queryable Encryption | No |
LDAP Integration | Yes |
Database-level auditing | Yes |
Bring your own KMS | No Azure key vault only |
MongoDB | Microsoft Cosmos DB Emulation API | |
---|---|---|
Database support delivered directly by MongoDB engineers | Yes Available with an optional support contract | No |
Consulting services from engineers with multiple years of MongoDB expertise | Yes MongoDB Consulting Services | No |
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 expertise | No |