When does DynamoDB throttle request?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
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:
- 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.
- 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
- 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.
- 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
- 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.
- Rate Limiting:
- Although rare, if the request rate exceeds the soft limits defined for a region or account, requests might be throttled.
- 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
- Auto-Scaling:
- Utilize DynamoDB Auto Scaling to automatically adjust table and index capacities in response to actual traffic patterns.
- Efficient Data Access Patterns:
- Optimize your queries and updates to minimize the number of requests and to adhere to the capacity limits effectively.
- Exponential Backoff:
- Implement exponential backoff in your applications to gracefully handle throttled requests by retrying them after incremental wait times.
- 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
| Scenario | Throttling Cause | Mitigation Strategy |
| Provisioned Capacity | Exceeding RCUs/WCUs | Auto-scaling, adjust provisioned capacity |
| Short-term Capacity Exceed | Load spike surpassing burst capability | Optimize requests, manage burst durations |
| On-Demand Capacity | Continuing high throughput exceeding burst limits | Design for elasticity using best practices |
| GSI Throughput | Exceeded capacity for GSIs | Auto-scaling, manage indexing needs |
| Aggregate Size Limit | Large or numerous request sizes | Optimize 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.

