I want to resolve my API throttling errors that occur when I use AWS Elastic Beanstalk.
Short description
API calls to an AWS service can't exceed the maximum allowed API request rate per second. The quota is shared across all resources for each AWS account and AWS Region.
If API requests exceed the maximum rate per second, then you receive a "Rate Exceeded" error message and API calls are throttled.
You can receive errors from API calls that are made directly to Elastic Beanstalk and other AWS services that Elastic Beanstalk manages. The risk for throttles increases as usage in the account increases or as you add more resources to the same account.
Note: When AWS services are adjusting to increases in account usage, API call quotas can vary. It's a best practice to dynamically adjust the rate that you use the API.
Resolution
Find the source of high API calls
Complete the following steps:
- In your Elastic Beanstalk event stream, identify the throttling error. Note the time frame when you received the error.
Note: If API calls are coming from an application or script, then look for the time frame in your application logs.
- For requests that are within the time frame, use Athena queries or AWS CloudTrail Event history to view events and verify the eventName, eventSource, and userAgent. Match the timestamp of the error in the Elastic Beanstalk events stream or logs with the errors in the CloudTrail logs.
You can use Amazon CloudWatch to monitor your API usage metrics.
Third-party applications can make continuous calls to Elastic Beanstalk or AWS services that Elastic Beanstalk manages. If you grant a third-party application permission to make API calls in your account, then make sure that you monitor the API calls.
Use best practices to reduce API usage
Use error retries, exponential backoffs, and jitter to limit the rate of API calls. If the default retry logic isn't sufficient, then adjust the SDK configuration settings.
Note: When you call the SDK, use backoff, retry, and jitter logic in your code.
Use only custom scripts to make API calls every second. For complex use cases, create a caching layer or a multi-account strategy. It's a best practice not to allow a single account to increase too much. Separate development or testing resources from production resources so that the development and testing resources don't take API usage from the production resources.
Request an increase to your API call rate quota
You can request an API call rate quota increase. However, you must provide a strong justification. AWS Support reviews your API usage to make sure that you're following best practices.
Include the following information in your request:
- Your Region and the time frame that the throttling is occurring in.
- The API call that you're using and call rate that you need.
- A detailed use-case justification, such as the business and technical needs for the increase.
- Results or related information for error retires, exponential backoffs, and jitter.
Related information
Retry behavior
Exponential backoff and jitter
Logging Elastic Beanstalk API calls with AWS CloudTrail
CloudWatch usage metrics
Benefits of using multiple AWS accounts