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 of the 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 on different aspects.
1. 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.
2. 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.
3. 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.
4. 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.
5. 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 complex than DynamoDB queries.
6. 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’.
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. Here is an example of the DynamoDB stream use case by AWS.
In Azure, we have ‘Change Feed’ which is mainly focused on containers in Azure Cosmos DB. It works similar 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 must 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.
7. 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.
Let’s see a price comparison of DynamoDB and CosmosDB:
*CosmosDB has a single unit (Request Unit) for read and write operations. So
$0.25/ 1 million is the combined cost of read and write operations.
8. 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:
{
"TableName":"Music",
"KeySchema":[
{
"AttributeName":"Artist",
"KeyType":"HASH",
},
{
"AttributeName":"SongTitle",
"KeyType":"RANGE"
}
],
"AttributeDefinitions":[
{
"AttributeName":"Artist",
"AttributeType":"S"
},
{
"AttributeName":"SongTitle",
"AttributeType":"S"
}
],
"ProvisionedThroughput":{
"ReadCapacityUnits":1,
"WriteCapacityUnits":1
}
}
CosmosDB JSON structure:
{
"Artist":"",
"SongTitle":"",
"AlbumTitle":"",
"Year":9999,
"Price":0.0,
"Genre":"",
"Tags":""
}
Wrapping up
Azure CosmosDB and Amazon DynamoDB are both quite similar, and each has some positive and negative points. We compared them in many aspects. I hope it will be helpful for you.
所有评论(0)