Comparing Microsoft Cosmos DB And MongoDB (2024)

BLOGAtlas Vector Search voted most loved vector database in 2024 Retool State of AI report — Read more >>

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 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 migrationYes 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

Yes

Atlas Data Federation

No

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

Yes

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
Queries submitted to multiple replicas for consistent low latency

Yes

No

Pause and resume clusters

YesNo
Data explorer

Yes

Directly in Atlas UI, or via MongoDB Compass

Yes
SQL-based connectivity

Yes

MongoDB Connector for Business Intelligence

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

Yes

MongoDB Charts

No
Database supported in on-premise and hybrid deployments

Yes

MongoDB Enterprise Advanced

No
Embeddable database with sync for mobile devices

Yes

MongoDB Atlas Device Sync

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 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

Yes

Atlas Data Federation

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

Yes

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
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

Yes

MongoDB Connector for Business Intelligence

Native data visualization without 3rd party BI tools

Yes

MongoDB Charts

Database supported in on-premise and hybrid deployments

Yes

MongoDB Enterprise Advanced

Embeddable database with sync for mobile devices

Yes

MongoDB Atlas Device Sync

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

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 replicationDistribute 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 replicationDistribute 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 replicationDistribute 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 storageYes

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 restoreYesYes
Queryable backupsYesNo
Automated & consistent snapshots of sharded clustersYesNo
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 controlYes

Limited

Coarse-grained roles only

AWS VPC PeeringYesN/A
Encryption of data in-flight

Yes

TLS/SSL as standard

Yes
Encryption of data at-restYesYes

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

YesNo

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

YesNo
LDAP IntegrationYesYes

Database-level auditing
Track DDL, DML, DCL operations

YesYes
Bring your own KMSYes

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

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 expertiseNo

Get started with MongoDB Atlas today

Comparing Microsoft Cosmos DB And MongoDB (2024)

FAQs

Is Cosmos DB better than MongoDB? ›

MongoDB excels in cost-effectiveness, flexibility, and community support, while Cosmos DB offers global distribution, multi-model support, and automatic scalability. Ultimately, selecting the right database solution is essential to ensure optimal performance, efficiency, and success for your business.

What are the disadvantages of Cosmos DB? ›

One of the main weaknesses of Cosmos DB is that users need to be experienced to tune and configure it well. As a result you can end up with a cost over-run of Cosmos DB is not configured properly. Learning Cosmos DB takes time, it is nothing like regular SQL or MS SQL.

What is the Azure equivalent of MongoDB? ›

Azure Cosmos DB for MongoDB provides a powerful fully managed MongoDB compatible database while seamlessly integrating with the Azure ecosystem.

Is Azure Cosmos DB deprecated? ›

Yes, that is correct. The Microsoft Azure CosmosDB Table API has been deprecated and replaced with Azure.

Which database is better than MongoDB? ›

As a relational database management system, MySQL has a more rigid structure than MongoDB. MySQL uses a fixed schema and organizes data into a row and table.

Why is Azure Cosmos DB so expensive? ›

Azure Cosmos DB can be costly due to its robust features, global distribution, and low latency performance. Factors like provisioned throughput, storage, and data transfer contribute to expenses. Users pay for the scalability, flexibility, and advanced capabilities provided by the service.

Why is Cosmos DB so slow? ›

Request throttling is the most common reason for slow requests. Azure Cosmos DB throttles requests if they exceed the allocated request units for the database or container. The SDK has built-in logic to retry these requests.

What is Cosmos DB best for? ›

Social Applications

A common use case for Azure Cosmos DB is to store and query user generated content (UGC) for web, mobile, and social media applications. Some examples of UGC are chat sessions, tweets, blog posts, ratings, and comments.

Is Cosmos DB SQL or NoSQL? ›

Azure Cosmos DB for NoSQL is a native non-relational database service and vector database for working with the document data model. It can arbitrarily store native JSON documents with flexible schema.

What is the Microsoft equivalent of MongoDB? ›

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.

Can I host MongoDB on Azure? ›

Can I use MongoDB with Azure? MongoDB Atlas is available on the Azure Marketplace. With just one click, you can get started today with our pay-as-you-go option.

Can we store documents in Cosmos DB? ›

Consider, replicating the same scenario using CosmosDB, which provides low latency reads and writes, even in single write and multiple read nodes with its geo-replication feature. You can store all the information in a single object in CosmosDB, which includes all the documents, images, amenities information.

What are the limitations of Cosmos DB? ›

Per-item limits
ResourceLimit
Maximum size of an item2 MB (UTF-8 length of JSON representation) ¹
Maximum length of partition key value2048 bytes (101 bytes if large partition-key isn't enabled)
Maximum length of ID value1023 bytes
9 more rows
Aug 14, 2024

Is Azure Cosmos DB free forever? ›

Free tier is available for all API accounts with provisioned throughput, autoscale throughput, single, or multiple write regions. Free tier lasts indefinitely for the lifetime of the account and it comes with all the benefits and features of a regular Azure Cosmos DB account.

What is the security issue with Azure Cosmos DB? ›

The 'CosMiss' vulnerability allowed an unauthenticated user to obtain read and write access to Azure Cosmos DB Notebooks, inject code, and overwrite code – constituting remote code execution (RCE).

Is Cosmos DB reliable? ›

Azure Cosmos DB guarantees SLAs for availability and P99 latency through all automatic maintenance operations that the system performs. Azure Cosmos DB offers: Individual node outage resiliency.

What is the best NoSQL database? ›

Best NoSQL Databases Shortlist
  • HBase — Best column-oriented database for storing very large datasets.
  • Neo4j — Best graph-based NoSQL database.
  • Oracle Coherence — Best cloud- and grid-based NoSQL database.
  • MongoDB — Best document-based NoSQL database.
  • Redis — Best key-value NoSQL database.
Jun 18, 2024

Why is Cosmos DB slow? ›

Request throttling is the most common reason for slow requests. Azure Cosmos DB throttles requests if they exceed the allocated request units for the database or container. The SDK has built-in logic to retry these requests.

References

Top Articles
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 6150

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.