DynamoDB
Amazon Web Services
throughput calculation
database limitations
scalable database

How is Amazon DynamoDB throughput calculated and limited?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Amazon DynamoDB Throughput Calculation and Limitations

Amazon DynamoDB is a fully managed NoSQL database service designed for applications that require consistent, single-digit millisecond latency at any scale. One of the essential aspects of utilizing DynamoDB effectively is understanding how throughput is calculated and what the inherent limitations are. This article dives deep into the mechanics of DynamoDB throughput, providing both technical explanations and examples.

Understanding DynamoDB Throughput

Throughput in DynamoDB is the measure of the number of read and write operations per second (read capacity units and write capacity units) that your application can perform. In DynamoDB, throughput is determined by two main parameters for each table:

  1. Read Capacity Units (RCUs): Each RCU provides the ability to perform one strongly consistent read per second, or two eventually consistent reads per second, for items up to 4 KB.
  2. Write Capacity Units (WCUs): Each WCU allows you to perform one write per second for items up to 1 KB.

Throughput Calculation

Example Calculation

Let's consider a scenario where a DynamoDB table is configured with a provisioned capacity of 10 RCUs and 5 WCUs. Here's how you can interpret these figures:

  • Read Capacity Units:
    • Strongly Consistent Reads: Can perform up to 10 reads of 4 KB per second.
    • Eventually Consistent Reads: Can perform up to 20 reads of 4 KB per second since they consume half the RCU.
  • Write Capacity Units:
    • Can perform up to 5 writes of 1 KB per second.

If you need to read items larger than 4 KB, you must consume more RCUs. For instance, reading an 8 KB item would require 2 RCUs for a strongly consistent read.

Factors Affecting Throughput

  • Item Size: Larger items consume more RCUs and WCUs. For every additional 4 KB (or portion thereof) in an item, an additional RCU (for reads) or WCU (for writes) is required.
  • Consistency Model: The choice between strongly consistent and eventually consistent reads impacts the RCU consumption.
  • Batch Operations: Operations like batch reads or writes may combine multiple RCUs or WCUs, affecting throughput calculations.

Auto Scaling

DynamoDB offers auto scaling capabilities, dynamically adjusting the provisioned throughput to respond to traffic changes. This auto-scaling is based on user-defined policies, allowing a table's RCUs and WCUs to scale in response to real-time application demand.

On-Demand Capacity Mode

For applications with unpredictable traffic, DynamoDB's on-demand capacity mode automatically scales RCUs and WCUs. This mode eliminates the need to manage capacity, charging instead based on the number of read/write requests your application performs.

Limits and Constraints

  • Provisioned Capacity Constraints:
    • Tables must respect the maximum provisioned capacity set; exceeding this results in ProvisionedThroughputExceededException.
  • Partition Key Restrictions: Hot partitions (partitions receiving disproportionate requests frequently) can lead to throttling if they exceed partition-level throughput.
  • Service Quotas: AWS imposes account-specific and default limits on the maximum RCUs/WCUs per table or account. These limits can be increased by AWS upon request.

Summary Table

ParameterDescriptionCalculation
Read Capacity Unit (RCU)One 4 KB strongly consistent read per second or two eventually consistent readsStrong: 1 RCU for 4KB (Eventual: 1 RCU for 8KB)
Write Capacity Unit (WCU)One 1 KB write per second1 WCU for 1KB
Consistency ModelStrong/Eventually consistent affects RCU useDoubles reads for eventual consistency
Auto ScalingDynamically adjusts throughput based on policiesAdjusts RCUs/WCUs automatically
On-Demand ModeAutomatically scales capacity as neededCharges based on request count
Hot PartitionsCan lead to throttling if a partition is overloaded with requestsAvoid dense traffic to singular partition

Conclusion

Understanding DynamoDB's throughput calculation and limitations is essential when planning your application's capacity needs. Dynamic features like auto scaling and on-demand capacity modes provide greater flexibility, enabling applications to handle varying load seamlessly. However, careful planning of partition keys and workloads is crucial to avoid performance bottlenecks. Managing throughput effectively ensures a responsive and cost-efficient application.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.