DynamoDB vs Amazon Keyspaces - The Ultimate Comparison
Written by Lakindu Hewawasam
Published on September 14th, 2022
Time to 10x your DynamoDB productivity with Dynobase [learn more]
Amazon DynamoDB and Amazon Keyspaces are two popular NoSQL database services offered by AWS. Both services provide extraordinarily scalable and high-performing databases to process serverless application requests with minimal latency. Therefore, deciding between the two is often difficult.
So, this article aims to provide an in-depth review between Amazon DynamoDB and Amazon Keyspaces to understand each service and how they compare against each other.
DynamoDB and Amazon Keyspaces: An Overview
Amazon DynamoDB is a serverless, fully-managed NoSQL and key-value database. It allows developers to build high-performing, scalable, demanding, and mission-critical applications with single-digit millisecond request/response latency. Additionally, DynamoDB implements a scalable partition approach that provides an O(1) time complexity. So, regardless of the dataset size, DynamoDB will always respond to single-digit millisecond latency while automatically replicating data across three availability zones within a region.
Amazon Keyspaces is a serverless, fully-managed NoSQL database built for managing Cassandra workloads. Amazon Keyspaces also offer consistent, single-digit millisecond latency at scale and can process over 1000 requests per second. Additionally, it provides three-time data replication across multiple availability zones ensuring high availability.
DynamoDB and Amazon Keyspaces: Shared Attributes
Both databases share some similarities. For instance, both databases are NoSQL, key-value, and fully managed databases powered by serverless. Therefore, both databases can scale horizontally and withstand extreme loads with no performance loss.
On the other hand, these two databases also have some significant differences. For example, DynamoDB has a limit of 400KB per item, while Amazon Keyspaces has a limit of 1MB per row.
Performance & Latency
DynamoDB can handle requests at single-digit millisecond latency despite the request count. For example, it can handle 10 trillion requests per day while offering single-digit millisecond latency to all requests with no performance loss.
Additionally, it uses a request router that redirects the request to a partition in which the data is stored (in the SSD array), ensuring that DynamoDB only scans a limited set of data (even if your dataset is one terabyte). Finally, it achieves a time complexity of 0(1), ensuring that DynamoDB consistently performs well as the dataset scales.
Additionally, integrating DAX (DynamoDB Accelerator) can help improve the response time to single-digit seconds.
Amazon Keyspaces is a high-performing database that can offer single-digit millisecond latency to client requests, thus allowing developers to build low-latency and highly-scalable mission-critical Cassandra workloads.
Availability & Durability
DynamoDB spreads incoming requests across multiple services to distribute the load and avoid performance bottlenecks and throttling. Additionally, DynamoDB replicates data across multiple availability zones (AZ), ensuring high availability if an AZ goes down.
Amazon Keyspaces also replicates your data thrice across multiple availability zones to improve durability. It ensures that your data will be accessible even if one availability zone goes down. Additionally, Amazon Keyspaces offers an availability of 99.99% in their SLA.
DynamoDB supports encryption at rest using AWS Key Management Service. With DynamoDB, developers can utilize three kinds of KMS keys to encrypt data.
- AWS Owned Key: This is the free encryption type offered by AWS, where DynamoDB owns and manages the encryption key.
- AWS Managed Key: This is where you can store the key in your AWS account and let AWS KMS manage it.
- Customer Managed Key: This is where you are given the ability to create and manage the KMS key.
Finally, DynamoDB uses AWS IAM to help developers define granular access to DynamoDB resources across multiple services (such as Lambda).
Amazon Keyspaces uses encryption at rest and transit by default. Out of the box, Amazon Keyspaces uses an AWS Owned Key for encryption. At the same time, developers are given the capability to configure the encryption to use either an AWS Managed or Customer Managed Key.
Scaling DynamoDB depends on the way the data structure is modeled. For example, if you were building an application that uses a team and partitioned data based on teams, DynamoDB would start to throttle as the users per team grow. As a result, the number of requests that enter the partition increase and creates a hot partition that can cause performance issues as the system scales.
However, if modeled correctly, DynamoDB can serve over a million customers with single-digit millisecond latency, making the service extremely scalable.
Amazon Keyspaces offers two approaches to implementing scalability.
- On-Demand Capacity: Amazon Keyspaces will automatically manage the number of reads and writes per second and scale up automatically when needed to handle sudden request loads. Suitable for unpredicted workloads.
- Provisioned Capacity: Developers can define the number of reads and writes per second they expect for a single table. However, it is recommended to use this approach only when the workload is predictable.
DynamoDB offers two kinds of data backup.
- Point-in-time recovery: DynamoDB continuously creates backups for a given table and lets developers perform rollback operations within the last 35 days.
- On-demand: On-demand backups allow developers to create full table backups with no performance overhead.
Amazon Keyspaces also uses point-in-time recovery to allow developers to restore data of a given table in case of accidental deletes within the last 35 days.
DynamoDB charges you on a pay-as-you-use basis. But, if you use a provisioned billing model, you will have to pay for the provisioned throughput even if you do not utilize it.
The DynamoDB pricing plans are further explained below.
- On-Demand Pricing - AWS calculates the bill based on the throughput consumed for the month. You may also get additionally billed for the backup storage and other DynamoDB services you may consume.
- Provisioned Pricing - AWS charges a developer for the provisioned throughput.
Amazon Keyspaces also offers 2 pricing models:
- On-Demand Pricing - You are only billed for the number of reads and writes per second/month.
- Provisioned Pricing - You are billed for the number of reads and writes per second you have provisioned.
Besides, Amazon Keyspaces creates the cost for every million requests (reads or writes per month). For example, Amazon Keyspaces charges 1.8212 USD per million write request units in the Asia Pacific region. These prices can differ based on the region you select.
DynamoDB and Amazon Keyspaces Use Cases
DynamoDB is a good option for building applications that process millions of concurrent requests per second and require low-latency responses.
You can use DynamoDB in the following situations:
- Building scalable, fast applications.
- Building a near-real-time application such as a sensory application.
Since Amazon Keyspaces is a scalable and serverless NoSQL Database like DynamoDB, both of these share similar use cases, for example, you can use Amazon Keyspaces to build applications that require low latency.
However, I recommend using Amazon Keyspaces only when planning to move an Apache Cassandra workload to the cloud.
This article provided an in-depth guide on DynamoDB and Amazon Keyspaces to help you understand how each service works and compare to each other. It is essential to understand that there is no "best" database you can use, as it depends on your use case.
I hope that you found this article helpful! Thank you for reading!