Amazon DynamoDB
throughput calculation
capacity units
read and write limits
cloud database management

How is Amazon DynamoDB throughput calculated and limited?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Amazon DynamoDB is a fully-managed NoSQL database service that provides reliable performance while maintaining scalability. A critical aspect of managing a DynamoDB table is understanding how throughput is calculated and limited. This understanding ensures optimal performance and cost management.

Throughput in DynamoDB

DynamoDB throughput refers to the speed at which data can be read from or written to a table. Throughput is provisioned in two distinct units:

  • Read Capacity Units (RCUs): One RCU represents one strongly consistent read per second, or two eventually consistent reads per second, for items up to 4 KB in size.
  • Write Capacity Units (WCUs): One WCU represents one write per second for items up to 1 KB in size.

How Throughput is Calculated

Read Throughput

  1. Strongly Consistent Reads:
    • Consumes 1 RCU per 4 KB read per second.
  2. Eventually Consistent Reads:
    • Consumes 0.5 RCU per 4 KB read per second, effectively doubling the read throughput for the same capacity.
  3. Transactional Reads:
    • Consumes 2 RCUs per read per second for 4 KB, providing ACID properties.

Example: If you perform 10 strongly consistent reads of 8 KB items every second, you would consume 20 RCUs (10 reads * 2 RCUs per read).

Write Throughput

  • Each write of an item up to 1 KB consumes 1 WCU. If the item size increases, the required WCUs increase accordingly.

Example: If you write 100 items every second but each item is 2 KB in size, you would need 200 WCUs (100 writes * 2 WCUs per write).

Capacity Modes

  1. Provisioned Capacity:
    • You specify the number of RCUs and WCUs required, and you pay for that capacity, regardless of whether you fully utilize it.
  2. On-Demand Capacity:
    • You pay for the reads and writes your application performs. This mode automatically scales to handle varying loads without the need for provisioning.

Calculated Example with Provisioned Capacity

Suppose you have a table with 10 RCUs and 5 WCUs, and you plan to execute the following operations:

  • 100 strongly consistent read requests per second, retrieving items averaging 1 KB in size.
  • 50 write requests per second for items averaging 1 KB in size.

Calculation:

  • Reads: Each request consumes 1 RCU (since 1 KB < 4 KB per RCU). For 100 requests, 100 RCUs are required, exceeding provisioned capacity.
  • Writes: Each request consumes 1 WCU (since 1 KB = 1 WCU). For 50 requests, 50 WCUs are required, exceeding provisioned capacity.

Limits and Constraints

  1. Throughput Limits:
    • Maximum table-level throughput is 40,000 RCUs or 40,000 WCUs for a single region (expandable upon request with AWS).
  2. Item Size:
    • Each item in a table can be up to 400 KB.
  3. Burst Capacity:
    • Tables using provisioned throughput can accumulate unused capacity for brief bursts, providing temporary flexibility.
  4. Throttling:
    • If a table's throughput exceeds its provisioned capacity, DynamoDB will throttle requests. AWS recommends enabling auto-scaling to help manage this.

Key Points Summary

FeatureDescription
Read Capacity Unit (RCU)1 RCU = 1 strongly consistent read/sec OR 2 eventually consistent reads/sec for up to 4 KB items.
Write Capacity Unit (WCU)1 WCU = 1 write/sec for up to 1 KB items.
Provisioned CapacityPre-defined RCUs/WCUs, burst capacity applicable.
On-Demand CapacityPay per request, auto scales with application demand.
ThrottlingRequests over provisioned limits are throttled; consider auto-scaling to adjust limits dynamically.
Max Item Size400 KB

Additional Details

Auto-scaling

DynamoDB's auto-scaling feature enables automatic adjustment of provisioned throughput. This is crucial for efficiently handling unexpected workloads and minimizing costs by only paying for the needed capacity.

Monitoring and Alarming

AWS CloudWatch can be utilized to monitor DynamoDB usage and trigger alarms when throughput utilization approaches thresholds. This proactive monitoring helps prevent throttling and maintains application performance.

Overall, understanding how DynamoDB throughput is calculated and limited allows developers to design efficient data operations, manage costs effectively, and ensure consistent application performance. Proper usage of capacity modes, scaling features, and monitoring enhances the DynamoDB experience, delivering a robust NoSQL service on AWS.


Course illustration
Course illustration

All Rights Reserved.