Cosmos DB vs MongoDB

  • Azure Cosmos DB is comparatively faster than MongoDB in most common use cases, although MongoDB performs better over 1MB payload.
  • MongoDB offers more flexibility in terms of setup. It runs on-prem, any cloud provider (Google Cloud Platform, AWS, Azure and more).
  • We found Azure Cosmos DB to be 93% cheaper for reads and around 20% cheaper for writes than MongoDB Atlas depending on workload characteristics (see TCO table below).
  • At Cazton, we work with different kinds of database technologies and have more than a decade of experience in creating highly scalable and efficient systems that use multiple database technologies that are complementary to each other.
  • We have helped many Fortune 500 clients, mid-size companies and startups create a scalable data strategy with high performance.
  • Want a detailed report for Cosmos DB, MongoDB, Cassandra, Redis, Postgres, SQL Server, MySQL, ElasticSearch and Solr? Contact us at info@cazton.com.

Just a few years ago, it was acceptable to have offline data processing that enabled employees in analyzing big data. That analysis brought continuous improvement to an existing business and the customer experience; however, there has been a paradigm shift. Customers expect real time predictions and they expect to act on them instantly. So, we need to use incoming information and map it with our existing data models to make real-time predictions.

Now, more than ever, big data analysis is a necessity for a company to excel and grow. The amount of data shared and transferred between humans is unimaginable and to manage, analyze, make real-time predictions and decisions using that data is a daunting task. Many organizations prefer polyglot persistence over a single data storage technology as they have to deal with different types of data.

Over the last decade the popularity of NoSQL databases have skyrocketed. This is mostly because of the increased number of devices including mobile as well as IOT. NoSQL databases have been a strong contender for data storage and processing requirements of modern applications. These databases can be deployed as distributed systems, which makes them more reliable and faster while querying for data. They are inherently more scalable than SQL databases as they allow you to scale vertically and horizontally whereas most SQL databases are vertically scalable by design.

In the technology industry, there can never be a “one size fits all” solution and hence one has to be ready to adapt to different technologies to solve different business and technical problems. At Cazton, we work with different kinds of database technologies and have more than a decade of experience in creating highly scalable and efficient systems that use multiple database technologies that are complementary to each other. We have helped many Fortune 500 clients, mid-size companies and startups create a fool-proof data strategy.

Over the last couple of years, we have seen tremendous growth and demand for both Azure Cosmos DB and MongoDB. Both these technologies are promising and offer features that often complement each other. However the question still remains, which among the two performs better? To analyze and understand which one is better, we ran benchmarking code which explicitly performed CRUD (Create, Read, Update, Delete) operations against both the databases.

What is Azure Cosmos DB?

Azure Cosmos DB is a globally distributed, multi-model NoSQL database service that provides strong consistency, extremely low latency, high availability, throughput and up to five consistency levels backed by solid service level agreements (SLAs). The core idea behind building such a database technology was to make it horizontally scalable and globally distributed. This means that the data gets much closer to the customers as it is replicated and stored across multiple Azure data centers in various regions. Azure Cosmos DB guarantees less than 10ms for reads and less than 10 ms latency for writes [MB1] less than 1Kb of data. Note that all reads and writes are served from a local region, and then replicated according to the selected consistency model. Learn more.

What is MongoDB?

MongoDB is a document-based distributed NoSQL database that can be used for modern, distributed and cloud based applications. It stores data in BSON format - binary encoding of JSON-like documents, and supports arrays and nested JSON objects. It offers SQL-like features like ACID transactions, ad hoc queries, joins, indexing, and much more.

MongoDB offers an option to run it as a service. This means you don't need to worry about setting up physical hardware, installing software or configuring for performance. MongoDB Inc., the company which makes the software for MongoDB, has a service called Atlas. You can leverage MongoDB Database as a Service on any cloud platform like Google Cloud Platform, Azure or AWS. However if you wish to keep it local, you can also install it as a service on Windows and Linux platforms. Learn more.

Benchmarking Azure Cosmos DB (SQL API) and MongoDB service on Atlas

The benchmarking effort aims to examine both Azure Cosmos DB (SQL API) and MongoDB service on Atlas and compare their performance using intuitive and easily repeatable scenarios in a cloud-based infrastructure. Using Azure and explicit CRUD operations we were able to create a benchmark that allowed each technology to shine and put its best foot forward. TCO estimates were created using public performance information and a straightforward, data-driven approach to calculations.

  • Machine Specifications: We ran the benchmarking code on an Azure VM in the same region as the databases. Both Azure Cosmos DB and MongoDB service on Atlas were running in the West coast (US).

    Cloud Provider Azure
    Machine Size Intel Xeon Platinum 8272CL CPU 2.60GHz
    Cores 1 CPU, 8 logical and 4 physical cores
    Image Ubuntu 18.04
    Software Development Kit .NET SDK 5.0.301
    Host .NET 5.0.7 (5.0.721.25508), X64 RyuJIT
  • Strategy: The benchmarking approach included warmup steps to ensure the database instances operated in a representative manner and repeated operations to ensure a statistically significant set of results, including percentile grouping analysis. For the benchmarking effort, we tested CRUD (Create, Read, Update, Delete) operations on Azure with the database technologies and benchmarking code running in the same region. We tested common and uncommon scenarios to assess performance in Microsoft's Azure environment.

    We utilized BenchmarkDotNet and NBomber to simulate various load scenarios on the databases. The CRUD operations were performed with the following payloads: 1KB, 10KB, 100KB, 1MB, 2MB. Azure Cosmos DB has a payload limit of 2MB. We also made sure that both databases would simultaneously get hits with different user counts ranging from 1 to 1000 users.

Benchmarking Results

For 1 KB Payload: Azure Cosmos DB performed better for create, update and delete operations whereas MongoDB did well for read operation.

For 10 KB Payload: Again, Azure Cosmos DB performed better for create, update and delete operations whereas MongoDB did well for read operation.

For 100 KB Payload: Here Azure Cosmos DB performed better for create and read operations whereas MongoDB did well for update and delete operations.

For 1 MB Payload: As the payload size increases...

Software Consulting

Would you like some world class consultants be at your service? Our experts are able to quickly identify, predict, and satisfy your current and future need.

Learn More

Trainings & Workshops

Would you like some world class training? Choose from one of the existing packages or contact us to create a training fully customizable for your needs.

Learn More

Recruiting & Staffing

Would you like some recruiting help? We provide full-service technical staffing to suit your needs: contract, contract-to-hire, full-time.

Learn More

Copyright © 2024 Cazton. • All Rights Reserved • View Sitemap