How an AWS API Call Works
- Your code calls the SDK, for example
s3.put_object - The SDK builds an HTTPS request to the regional endpoint (such as
s3.ap-south-1.amazonaws.com) - It signs the request with Signature Version 4 using your credentials. The signature proves who you are and that the request was not changed
- AWS checks authentication and IAM authorization, runs the action and returns JSON or XML
- The SDK turns errors into exceptions
The SDK and CLI sign automatically. You only sign by hand when calling an AWS API with plain HTTP. Presigned URLs also use SigV4 and carry the signature in the query string.
Error Types
| Code range | Meaning | Retry? |
|---|---|---|
| 4xx (client errors) | Your request is wrong: bad parameter, AccessDenied, ResourceNotFoundException, validation error | No (fix the request) |
429 / Throttling (ThrottlingException, ProvisionedThroughputExceededException, TooManyRequestsException, SlowDown) | Too many requests | Yes with backoff |
| 5xx (server errors) | Service problem: InternalError, ServiceUnavailable | Yes with backoff |
| Timeouts and connection errors | Network or overloaded service | Yes, if the operation is safe to repeat |
Exponential Backoff with Jitter
If many clients retry at the same moment they overload the service again. Exponential backoff waits longer after each failure (for example 100 ms, 200 ms, 400 ms, up to a cap). Jitter adds randomness so clients do not retry in lockstep.
You rarely write this yourself. AWS SDKs already retry throttling and transient errors with backoff. You tune the settings.
| Retry mode | Behavior |
|---|---|
legacy | Older default, fewer error types retried |
standard | Consistent across SDKs, backoff with jitter, retry quota |
adaptive | Standard plus client-side rate limiting that slows down when throttled |
- Set timeouts. The defaults can be long and hold threads
- Retry only idempotent operations safely. For others use an idempotency token (many APIs accept
ClientTokenorClientRequestToken) so a repeated request does not create duplicates - Put a limit on total retry time inside Lambda so you do not run into the function timeout
- For messages that keep failing use a dead-letter queue instead of infinite retries
Pagination
List APIs return pages. If a response has a NextToken, Marker or LastEvaluatedKey, there is more data. Ignoring this is a classic bug: you process only the first page (for example 1,000 S3 objects or 1 MB of DynamoDB results).
Waiters
A waiter polls until a resource reaches a state, with sensible delays and a maximum wait. It replaces hand-written sleep loops.
Handling Errors in Code
- Use
e.response['Error']['Code']ande.response['ResponseMetadata']['HTTPStatusCode'] - Log the request id (
ResponseMetadata.RequestId) so AWS Support can trace the call - Do not swallow all exceptions
Batching and Limits
| Service | Batch API | Limit to remember |
|---|---|---|
| DynamoDB | BatchGetItem, BatchWriteItem | 100 reads / 25 writes per call. Handle UnprocessedItems |
| SQS | SendMessageBatch, DeleteMessageBatch | 10 messages per call |
| SNS | PublishBatch | 10 messages |
| Kinesis | PutRecords | 500 records, 5 MB. Check FailedRecordCount |
| S3 | Multipart upload; delete up to 1000 keys per request | Parts 5 MB to 5 GB |
Batch calls can partially fail. Always inspect the response for unprocessed or failed entries and retry only those.
Practice Tasks
- Configure a client with
adaptiveretries and short timeouts - List all objects of a large bucket with a paginator
- Wait for an EC2 instance with a waiter
- Write a
BatchWriteItemcall that retriesUnprocessedItemswith backoff - Trigger a throttling error on a low-capacity DynamoDB table and watch the SDK retry
Conclusion
AWS calls are signed HTTPS requests to regional endpoints. Retry throttling and 5xx errors with exponential backoff and jitter (the SDK does this), never blindly retry 4xx errors, use paginators and waiters, set timeouts, use idempotency tokens, and check batch responses for partial failures.

