How can I avoid Route 53 API throttling errors?
Last updated: 2021-04-23
How can I avoid API throttling errors in Amazon Route 53?
When you perform bulk API calls to Route 53, you might receive an HTTP 400 (Bad Request) error.
A response header that contains a Code element with a value of Throttling and a Message element with a value of Rate exceeded indicates rate throttling. Rate throttling happens when the number of API requests is greater than the hard limit of five requests per second (per account).
If Route 53 can't process the request before the next request for the same hosted zone, Then subsequent requests are rejected with another HTTP 400 error. The response header contains both of the following:
- A Code element with a value of PriorRequestNotComplete
- A Message element with a value of the request was rejected because Route 53 was still processing a prior request.
API calls from AWS Identity and Access Management (IAM) users in the same account count towards global rate throttling for the account. API calls from these IAM users also impact API calls made from the AWS Management Console.
Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.
Use the following methods to avoid rate throttling.
Group individual operations of the same type into one change batch operation to reduce API calls using the AWS CLI or your preferred SDK.
For example, request to CREATE, DELETE, or UPSERT (update and insert) several records with one batch operation. Use the change-resource-record-sets command in the AWS CLI to perform bulk resource record operations.
Be aware that:
- UPSERT requests (update and insert) are counted twice.
- There are quotas for the elements and characters in change-resource-record-sets API calls.
Use error retries and exponential backoff
To avoid throttling, add error retries and exponential backoff to your Route 53 API calls. For example, use a simple exponential backoff algorithm that retries the call in 2^i seconds, where i is the number of retries.
Randomize start times
Randomize the start time for calling Route 53 APIs. Be sure that there aren't multiple applications processing the logic at the same time. Simultaneous requests can cause throttling.
Introduce "sleep time" between calls
If the code function calls to Route 53 APIs are consecutive, add "sleep time" between the two calls to minimize the risk of throttling.