Amazon Dynamo DB vs Azure Cosmos DB

Sebastian Kubiak
intive Developers
Published in
8 min readDec 13, 2022

Amazon DynamoDB and Azure CosmosDB both are widely used NoSQL databases with high scalability and availability. Here in this article, we will try to find out the differences between both databases based on different parameters.

Azure Cosmos DB

Azure Cosmos DB is a fully managed NoSQL database by Microsoft with high availability and low latency. It offers a single-digit millisecond response time with high-speed performance. It has natural support to all No SQL data models — graphs, APIs, and documents. As Cosmos DB is a fully managed database, you do not have to worry about management, patching, and updating; Azure takes care of administrative access to the database.

Azure offers a free plan for Cosmos DB. You get the first 1000 RU/s and 25 GB of storage for free. Later you can update your plan.

Some of the key benefits of using Azure Cosmos DB are:

  • Simplified development: Cosmos Db offers easy integration with open-source APIs, other Azure services, and multiple SDKs. You can use the language of your choice to build applications from .Net, Java, Node.js, to python. Further, it supports multiple API models such as MongoDB, SQL, Cassandra, and gremlin.
  • Guaranteed speed: It offers high speech and throughput with real-time access to the database. Also, Cosmos DB comes with instant elasticity and scalability in any azure region.
  • Fully managed: Cosmos DB offers end-to-end database management with automatic updates and management.
  • Business continuity: Azure Cosmos Db claims to offer a 99.999% availability with high security.
  • Robust security: Cosmos Db adheres to strict security and compliance standards. Also, all the data in Cosmos Db is encrypted.

Amazon Dynamo DB

Amazon Dynamo DB is a highly scalable and NoSQL database by AWS that allows you to store and retrieve any amount of data at a high-speed performance. It is a fully managed database with high security, backup, and restore options.

Amazon Claims that Dynamo DB can handle 10 trillion requests per day and can support more than 20 million requests per second. Amazon DynamoDB is an ideal option in applications where you need low latency at any scale like — web, gaming, IoT, and mobile.

Amazon Dynamo Db offers 25GB of storage and up to 200 million read/write requests per month for free and for more you can update the plan.

Some of the key features of Amazon DynamoDB are:

  • High Security and availability: Dynamo Db encrypts the data and it has an automatic backup and restore option to keep your data safe. Also, it offers a 99.999% availability.
  • Easy Integration: Amazon Dynamo Db is easy to integrate with other AWS services like AWS Lambda.
  • Fast: Dynamo Db offers high throughput with low latency at any scale. The data uploaded to Dynamo Db is replicated into multiple regions giving fast access to data globally.
  • Serverless: Dynamo Db is a serverless service of AWS. it means you do not have to worry about servers and infrastructures. You just have to upload your data and that’s it.

Difference between Azure Cosmos Db and Amazon Dynamo Db:

At first, Azure Cosmos Db and Amazon Dynamo Db both will sound similar to you and it is difficult to find which will be beneficial for your business. Here we will see what are the key differences in both of these databases and how to choose the perfect one for your organization. And for that, we will compare them in different aspects.

Migration

Cosmos Db offers more options to interact with the database in comparison to Dynamo Db. It offers support with MongoDB, SQL API, gremlin, Cassandra, and table API. It makes it easy to migrate on Cosmos Db from any other database. For example, if you are already using Mongo DB and you want to migrate to Cosmos DB then you will not have to make big changes in your database.

Scaling Rules

Both the databases support autoscaling — provisioned and on-demand. However, Cosmos DB has a request unit to interact with the database that is consist of reading and writing both and you scale that unit. But on the other hand in Dynamo DB read and write unit both are separate. So if you are writing more than reading then you can scale the writing unit independently. In cosmos DB, you can not scale both of them independently. It has a single Request unit for both read and writes operations.

Partitioning

Dynamo Db and Cosmos Db both allow you to store a large amount of data and query a large amount of data that may impact the performance. So partitioning is used to group data in partitions and provide high performance. Both databases offer partition keys to decide the placement of documents but Dynamo Db offers an optional sort key. So the data stored in a particular partition will be sorted.

The primary key in dynamo DB works like a hash attribute to derive the data in partitions whereas the sort key works as a range attribute to sort the data in partitions. Also, dynamo DB Global secondary index(GSI) works as a secondary partition key.

Pricing

Both databases work on an on-demand pricing model. However, their calculation metrics are different. In DynamoDb, you are charged $1.25 per million write request units and $0.25 per million read request units for on-demand capacity mode. For provisioned capacity mode, you are charged $0.00081 per write request and $0.00016 per reading request. You get the first 25 GB for free and later you are charged $0.25 per GB-month. You can decrease the cost of dynamo DB by having provisioned capacity billed by the hour and you can reserve the capacity for the long term to decrease the cost more.

In Cosmos Db for transactional data storage, you are charged $0.05 per 10,000 writes and $0.005 per 10,000 reads. It also costs $0.282 per million requests that include both read and write. The storage price is similar to Dynamo Db which is $0.25 GB/month.

Flexibility to Query

So Dynamo DB has a limited number of querying capabilities. However, Cosmos Db has more flexibility as it supports multiple databases and real-time feeds through Azure Functions. Further, Cosmos Db does not support mobile clients and needs a backend for it. But in Dynamo Db, you can use AWS Amplify Datastore which eliminates the need for the backend in mobile clients. Azure CosmosDB has SQL-like queries but is more complex than DynamoDB queries.

Triggering Mechanisms

In general, you can assume the standard way of data processing through a centralized repository where data is collected from multiple sources and then it is processed to achieve a certain goal. But it has an alternative way to make the process faster and work on data in real time. In DynamoDB the process is called ‘Streams’ whereas in CosmosDB it is called ‘Change feed’.

The DynamoDB stream is a collection of timely ordered events or modifications in DynamoDB tables. For example, if someone changes, inserts, updates or deletes any data then DynamoDB will record that event information immediately in a stream. So you can keep a record of all the modifications and use them in the future. DynamoDB streams are integrated with AWS Lambda so you can create triggers to respond to an event in DynamoDB. After enabling streams on a DynamoDB table, you can integrate it with Lambda using stream ARN. Whenever the table will be modified, a new record will appear in the stream and AWS Lambda will trigger the function after detecting a new stream record. You can modify this lambda function to do any task such as copy stream record into S3.

In Azure, we have ‘Change Feed’ which is mainly focused on containers in Azure Cosmos DB. It works similarly to DynamoDB streams to store any kind of changes in containers and then distribute the changes record to multiple departments for parallel processing. You can create Azure Functions that will be triggered by any new event occurring in the Azure CosmosDB change feed.

In DynamoDB you have to enable the streams first to capture the events whereas in CosmosDB Change feed is enabled by default. CosmosDB change feed supports inserts and updates events and if you want to capture deletes then you have to use a flag to capture soft deletes or Time to Live(TTL) period.

Service Legal Agreement(SLA)

Service Legal Agreement(SLA) refers to the policy that defines what a customer can expect from a service provider in terms of standards. AWS claims an uptime of 99.99% with DynamoDB standard SLA whereas Azure also claims an uptime of 99.99%. That means 1 in 10,000 requests, in an interval of 5 minutes, is allowed to fail.

For Global Tables, DynamoDB offers an uptime of 99.999%. However, every service comes with a different SLA and failure points. So your overall architecture SLA will depend on the services that you are using.

Data Availability in multiple regions

Amazon DynamoDB offers Global Tables that can be used to replicate the data in multiple regions automatically. For example — if you are having a web app with a global presence then you can create a replica of this app in different regions to provide a better user experience. With Global Tables, you do not have to do it manually. You can focus on your business logic and meanwhile, DynamoDB can handle the replication. There is no such provision in Azure CosmosDB.

JSON Structure

CosmosDB has a simple structure compared to DynamoDB. Let’s understand this with an example. Here we have data related to a song album. The first is the JSON structure in DynamoDB whereas the second one is in CosmosDB.

DynamoDB JSON structure:

Wrapping up

In summary, Azure Cosmos DB and Amazon DynamoDB are both fully managed, scalable, and highly available NoSQL databases. Cosmos DB offers easy integration with a variety of APIs and SDKs, as well as guaranteed speed and automatic management. DynamoDB offers high security and availability, fast performance, and easy integration with other AWS services. The main differences between the two are in terms of migration options, scaling rules, pricing, and support for transactions. Ultimately, the choice between the two will depend on an organization’s specific needs and requirements. Example scenarios:

  1. If an organization is currently using MongoDB and wants to migrate to a fully managed database without making significant changes to their existing database, they might choose Azure Cosmos DB because of its support for the MongoDB API.
  2. If an organization needs a database that can support transactions and has strict security and compliance requirements, they might choose Amazon DynamoDB because of its support for transactions and robust security features.
  3. If an organization needs a database that can be easily integrated with other Azure services and has support for a variety of languages and APIs, they might choose Azure Cosmos DB for its simplicity and versatility.
  4. If an organization needs a database that can handle high throughput and low latency at any scale, it might choose Amazon DynamoDB for its fast performance and global availability.
  5. If an organization is looking for a cost-effective database option, they might choose Amazon DynamoDB because of its free tier and flexible pricing options.
  6. If an organization is looking for a fully managed, scalable, and highly available NoSQL database and does not have specific requirements or constraints, either Azure Cosmos DB or Amazon DynamoDB would be a good option. Both databases offer strong security and compliance features, easy integration with other services, and good performance. In this case, the decision may come down to personal preference or the organization’s existing technology stack.

--

--

Sebastian Kubiak
intive Developers

See the license agreement, skip reading, click "I agree". Install. Programming but this time funny