DynamoDB
AWS
request throttling
database performance
cloud computing

When does DynamoDB throttle request?

System Design practice on Codemia

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

Practice system design

Introduction

Amazon DynamoDB is a highly performant and fully managed NoSQL database service that caters to applications requiring low-latency data access. Despite its efficiency, DynamoDB is subject to certain limitations and operational rules, including request throttling, to ensure system stability and fair resource distribution among users. Understanding when and why DynamoDB throttles requests is essential for designing resilient applications that maintain optimal performance.

Understanding Request Throttling

What is Throttling?

Request throttling in DynamoDB occurs when an application exceeds the available throughput limits assigned to a table or index. Throttling is a mechanism employed by DynamoDB to prevent overloading the system and to control resource usage effectively.

Provisioned and On-Demand Modes

DynamoDB supports two capacity modes that affect how throughput capacity is managed:

  1. Provisioned Mode: In this mode, you specify the number of read and write capacity units (RCUs and WCUs) for a table. Provisioned throughput indicates the maximum number of reads and writes per second that the table can support.
  2. On-Demand Mode: This mode automatically scales to handle the workload and charges you only for what you use. While it offers greater flexibility, it can still throttle under extreme traffic spikes, as there are inherent soft limits.

When Does Throttling Occur?

Provisioned Mode

  1. Exceeded RCUs or WCUs:
    • If requests exceed the provisioned read or write capacities, DynamoDB will throttle excess requests.
    • For example, if a table is provisioned with 100 read capacity units and an application attempts to read 200 capacity units in a second, the requests exceeding the 100 units will be throttled.
  2. Exceeding Short-Term Capacity:
    • Temporary surges in traffic, even within the provisioned limits, can cause throttling if the burst limits are exceeded. DynamoDB allows for short-term bursts for reads and writes, but continuous high traffic will lead to throttle.

On-Demand Mode

  1. Exceeded Burst Capacity:
    • On-demand mode supports burst capacity, allowing momentary traffic spikes. However, sustained high-throughput demands may lead to throttling once the burst capacity subsides.
  2. Rate Limiting:
    • Although rare, if the request rate exceeds the soft limits defined for a region or account, requests might be throttled.
  3. Maximum Request Size:
    • Large items or requests causing aggregate size limitations to be breached can also be subject to throttling.

Global Secondary Indexes (GSIs)

The throughput for any GSI also adheres to the same throttling principles as base tables. Exceeding the RCU or WCU provisioned for the index will result in throttling on queries, updates, or inserts targeting the index.

Avoiding Throttling

Best Practices

  1. Auto-Scaling:
    • Utilize DynamoDB Auto Scaling to automatically adjust table and index capacities in response to actual traffic patterns.
  2. Efficient Data Access Patterns:
    • Optimize your queries and updates to minimize the number of requests and to adhere to the capacity limits effectively.
  3. Exponential Backoff:
    • Implement exponential backoff in your applications to gracefully handle throttled requests by retrying them after incremental wait times.
  4. Sharding and Partitioning:
    • Distribute data evenly across partitions to avoid partition-level bottlenecks that could cause throttling.

Monitoring

Regular monitoring using AWS CloudWatch for the `ThrottledRequests` metric helps identify when and why throttling occurs.

Summary Table

ScenarioThrottling CauseMitigation Strategy
Provisioned CapacityExceeding RCUs/WCUsAuto-scaling, adjust provisioned capacity
Short-term Capacity ExceedLoad spike surpassing burst capabilityOptimize requests, manage burst durations
On-Demand CapacityContinuing high throughput exceeding burst limitsDesign for elasticity using best practices
GSI ThroughputExceeded capacity for GSIsAuto-scaling, manage indexing needs
Aggregate Size LimitLarge or numerous request sizesOptimize item sizes, review batch requests

Conclusion

Understanding when and why DynamoDB throttles requests allows developers to design applications that are both scalable and efficient. Following best practices for optimizing throughput, monitoring with CloudWatch, and correctly configuring table settings can greatly reduce the instances of throttled requests, ensuring a smooth and reliable user experience. By leveraging these strategies, your applications can fully leverage the power of DynamoDB while maintaining robust performance and scalability.


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.