- Mais recentes
- Mais votos
- Mais comentários
Looks like you are working with Python. Boto3 is the Python SDK for AWS. This link documents the best practices for error handling and retries.
Hope this helps!
Those links from @iBehr are worth a detailed look.
In summary there are 3 modes - Default/Legacy, Standard and Adaptive (experimental). You can configure the mode and number of retries (5 by default). Retrying is exponential backoff base 2 - this is particularly useful for handling throttling errors.
You can monitor retrying either in Boto3's logging (if enabled) or in the response to API calls. It's not clear from the doco but along with the documented structure returned by each call there's also metadata with RetryAttempts, e.g.:
'ResponseMetadata': {
'RequestId': '1234567890ABCDEF',
'HostId': 'host ID data will appear here as a hash',
'HTTPStatusCode': 400,
'HTTPHeaders': {'header metadata key/values will appear here'},
'RetryAttempts': 4
}
On the subject of AWS API request throttling, documentation is unclear about this generally (specific services like EC2 document it), but AWS Support said (in response to a case I raised a while back) there are many services that can experience request throttling:
- It varies service to service
- For some services all its APIs can be throttled, for others only some
- Not all AWS services document their throttling as they "might be dynamic in nature" (whatever that means).
Support said you can look for "ThrottleCount" and "RequestLimitExceeded" metrics in Cloudwatch but
- Support confirmed that not all services that have API throttling generate these (yet).
- I think only metrics that have generated data (i.e. a throttling event has happened) appear here, from what I've seen, so there's no way to inventory what ones can occur.
- Until I got the EC2/API metric enabled by requesting Support, EC2 API throttling wasn't visible in Cloudwatch Metrics. Support said there's no similar situation for other APIs.
- Seems that throttling on the EBS Direct API, even though this comes under "EC2", does not include throttling metrics under EC2/API.
EC2 uses a "token bucket" throttling method (see https://docs.aws.amazon.com/AWSEC2/latest/APIReference/throttling.html). Basically you have a bucket of tokens for making requests, which replenishes at a certain rate. If you run out, you get throttled and have to wait. Support said other services "likely" also use this method, but not always documented.
Conteúdo relevante
- AWS OFICIALAtualizada há 10 meses
- AWS OFICIALAtualizada há 7 meses
I am mostly using API Gateway, Lambda & DynomoDB. May I ask for you answer in the context of these services, please?