When an application communicates with AWS services, not every API request succeeds on the first attempt. Network interruptions, temporary service failures, request throttling, and server-side errors can cause an API operation to fail even when the application code is correct.
Consider an application that uploads files to Amazon S3 or reads customer records from DynamoDB. If a temporary network problem occurs during an API request, the application may receive an error. Without a proper retry strategy, the application might immediately report a failure to the user, even though the problem could disappear after a short delay.
AWS SDKs include built-in retry mechanisms that automatically handle many temporary failures. Developers do not need to implement retry logic for every AWS API operation manually.
However, understanding the default retry behavior is important because retries affect application response time, network traffic, resource consumption, and overall reliability.
In this article, we will explore how default retries work in AWS SDKs, understand different retry modes, examine exponential backoff and retry quotas, configure retry settings, and implement practical examples using Python and .NET.
What Is Retry Behavior in AWS SDKs?
Retry behavior is the mechanism that automatically sends a failed API request again when the failure is considered temporary or recoverable.
AWS SDKs classify errors and decide whether another attempt is appropriate. If the error is retryable and the configured attempt limit has not been reached, the SDK waits for a calculated period and sends the request again.
For example, consider an application that retrieves an order from DynamoDB.
The application sends a request to DynamoDB, but the service temporarily returns a server error. Instead of immediately returning the error to the application, the AWS SDK waits for a short period and retries the request.
If the next attempt succeeds, the application receives the expected response without needing to handle the temporary failure.
The general retry process follows these steps:
The application sends an API request using an AWS SDK.
AWS processes the request and returns a response.
If the request fails, the SDK classifies the error.
The SDK checks whether the error is retryable.
The SDK verifies the maximum attempt limit and retry quota.
If another attempt is allowed, the SDK calculates a backoff delay.
The SDK waits and sends the request again.
If the request succeeds or no more retries are allowed, the SDK returns the final result or error.
This process happens automatically inside the SDK.
The application generally receives either a successful response or the final exception after the retry process finishes.
Understanding the Default Retry Modes in AWS SDKs
AWS SDKs support three primary retry modes: standard, adaptive, and legacy.
Each mode handles failed requests differently. Choosing the right mode depends on the application's traffic pattern, AWS services, and reliability requirements.
Standard Retry Mode
Standard mode is the recommended default for most AWS workloads.
It uses exponential backoff with jitter and a retry quota to handle temporary failures and throttling responses.
When an API request fails with a retryable error, the SDK calculates a delay before attempting the request again.
For example, if an application receives a temporary HTTP 503 response, the SDK can wait for a short randomized interval before retrying.
Standard mode also maintains a retry quota. This prevents the SDK from continuously retrying requests when an AWS service is experiencing sustained failures.
Some important characteristics include:
Uses exponential backoff with jitter.
Supports retry quotas.
Handles transient and throttling errors differently.
Does not intentionally delay the initial request through a client-side rate limiter.
Provides consistent retry behavior across supported AWS SDKs.
Standard mode is generally the best starting point for web applications, background workers, APIs, and other AWS-integrated applications.
Adaptive Retry Mode
Adaptive mode includes the retry behavior available in standard mode and adds a client-side rate limiter.
The rate limiter monitors throttling responses and adjusts the rate at which requests are sent.
For example, suppose an application sends thousands of requests to a DynamoDB table. If the service repeatedly returns throttling errors, adaptive mode can reduce the request rate automatically.
Unlike standard mode, adaptive mode can delay even the initial request when the client-side rate limiter determines that requests should be slowed down.
This behavior can be useful for applications that repeatedly access a single AWS resource and can tolerate additional latency.
However, adaptive mode has an important limitation.
The rate limiter operates at the SDK client level. If one client sends requests to multiple resources, throttling against one resource can slow down requests to other resources that are not experiencing throttling.
For this reason, adaptive mode is not recommended as a general-purpose default for applications serving multiple tenants or accessing multiple resources through the same client.
Legacy Retry Mode
Legacy mode represents the older retry behavior used by some AWS SDKs.
Historically, different SDKs implemented their retry strategies differently. This resulted in variations in retry counts, backoff timing, and error classification.
Legacy mode exists mainly for backward compatibility.
It does not provide the same standardized retry quota behavior as standard mode across SDKs. As a result, an application can continue generating retry traffic during prolonged service failures.
For new applications, standard mode is generally a better choice.
Comparison of Retry Modes
Feature | Standard | Adaptive | Legacy |
|---|
Exponential backoff | Yes | Yes | SDK-dependent |
Jitter | Yes | Yes | SDK-dependent |
Retry quota | Yes | Yes | Varies by SDK |
Client-side rate limiting | No | Yes | No |
Can delay initial requests | No | Yes | No |
Cross-SDK consistency | Yes | Yes | Limited |
Recommended usage | General applications | Throttling-heavy workloads | Backward compatibility |
The standard mode is the recommended choice for most applications. Adaptive mode is more appropriate when request throttling is frequent and the workload can tolerate client-side rate limiting.
Understanding the Default Maximum Attempts
One of the most important retry settings is the maximum number of attempts.
AWS SDKs use a default maximum of three attempts for most service clients using the standard retry mode.
This includes the initial request and up to two additional retries.
For example:
Attempt | Operation | Result |
|---|
1 | Initial API request | HTTP 503 |
2 | First retry | HTTP 503 |
3 | Second retry | Success |
In this example, the SDK successfully completes the operation on the third attempt.
If all three attempts fail, the SDK returns the final error to the application.
It is important to understand that maximum attempts and maximum retries are not the same thing.
Maximum attempts include the original request, whereas maximum retries count only additional requests.
For example:
Configuration | Initial request | Additional retries | Total attempts |
|---|
Maximum attempts = 1 | 1 | 0 | 1 |
Maximum attempts = 2 | 1 | 1 | 2 |
Maximum attempts = 3 | 1 | 2 | 3 |
Maximum attempts = 5 | 1 | 4 | 5 |
DynamoDB and DynamoDB Streams clients have a different default in the updated standard retry behavior. They use four maximum attempts to accommodate their low-latency request profile.
These defaults can vary with SDK versions and service-specific configurations, so developers should verify the behavior of the SDK version used by their application.
How Exponential Backoff Works
Exponential backoff is a retry strategy that increases the waiting time between consecutive attempts.
Instead of immediately sending another request after a failure, the SDK waits for a calculated period.
The waiting period increases as the number of retries increases.
For example, suppose an application experiences repeated temporary failures. The SDK might use the following delay windows:
Retry attempt | Maximum delay window for a transient error |
|---|
First retry | 50 milliseconds |
Second retry | 100 milliseconds |
Third retry | 200 milliseconds |
Fourth retry | 400 milliseconds |
Fifth retry | 800 milliseconds |
These are upper bounds before randomization, not guaranteed waiting times.
The updated standard retry behavior uses the following formula:
delay = random(0, 1) * min(
20000,
base_delay * 2^retry
)
Here:
random(0, 1) generates a random value between zero and one.
base_delay represents the initial delay for the error category.
retry represents the retry index, starting at zero for the first retry.
20000 milliseconds is the maximum backoff cap.
For standard retry behavior, the base delay is different for transient and throttling errors.
Error category | Base delay |
|---|
Transient error | 50 milliseconds |
Throttling error | 1,000 milliseconds |
The SDK uses this approach to give temporary failures an opportunity to recover without continuously sending requests.
Why Jitter Is Important
Jitter adds randomness to retry delays.
Imagine that 1,000 application instances receive HTTP 503 responses at almost the same time.
If every application retries after exactly 50 milliseconds, they may all send another request simultaneously.
This can create another traffic spike and increase pressure on an already struggling service.
This situation is commonly called the thundering herd problem.
Full jitter distributes retry requests across a randomized delay window.
For example, instead of every application retrying after 50 milliseconds, different applications retry at different points between zero and 50 milliseconds.
This spreads the traffic and reduces synchronized retry bursts.
Understanding the AWS Retry Quota
Standard retry mode uses a retry quota to control repeated retry attempts.
The retry quota works like a token bucket. The SDK maintains an internal token balance and deducts tokens when it retries failed requests.
When requests succeed, tokens are replenished.
If the available tokens reach zero, the SDK stops performing additional retries and returns the error to the application.
This behavior is particularly useful during service outages.
Without a retry quota, applications could continue retrying requests even when the AWS service is experiencing widespread failures.
That would generate unnecessary network traffic and consume application resources.
How the Retry Quota Works
Under the updated standard retry behavior, the retry quota uses the following values:
Parameter | Value |
|---|
Initial token capacity | 500 |
Cost of transient retry | 14 tokens |
Cost of throttling retry | 5 tokens |
Tokens restored after a successful retry | Cost of the successful retry |
Tokens restored after a successful first attempt | 1 token |
Consider an application that repeatedly receives server errors.
Each retry consumes 14 tokens. If retries continue failing, the token balance gradually decreases.
When the balance reaches zero, the SDK stops retrying requests.
However, successful requests restore tokens and allow the SDK to continue retrying future failures.
The retry quota does not delay or block the initial request. It only controls whether additional retry attempts are allowed.
This mechanism helps applications fail faster during prolonged service disruptions instead of consuming resources waiting for requests that are unlikely to succeed.
Which AWS Errors Are Retried?
Not every AWS API error should be retried.
The SDK classifies failures into different categories based on their nature.
Transient Errors
Transient errors are temporary failures that may disappear when the request is sent again.
Common examples include:
HTTP 500 Internal Server Error.
HTTP 502 Bad Gateway.
HTTP 503 Service Unavailable.
HTTP 504 Gateway Timeout.
Connection resets.
Temporary network interruptions.
Request timeouts.
These errors can occur because of temporary service problems or network conditions.
Standard retry mode uses a shorter base delay for these errors.
Throttling Errors
Throttling occurs when an application sends requests faster than an AWS service or resource can handle.
For example, an application might send too many requests to a DynamoDB table within a short period.
AWS can return errors such as:
The SDK recognizes supported throttling errors and uses a longer backoff delay.
This gives the service more time to recover capacity before receiving another request.
Non-Retryable Errors
Some failures are caused by incorrect application requests or invalid configurations.
Repeating the same request will generally not solve these problems.
Examples include:
InvalidParameterException.
ValidationException.
ResourceNotFoundException.
AccessDeniedException.
Authentication failures caused by invalid credentials.
The SDK generally returns these errors without retrying.
The exact retry classification depends on the service response and SDK implementation. Developers should not assume that every HTTP 4xx response or every service exception follows the same rule.
Configuring Default Retry Behavior Across AWS SDKs
AWS provides common configuration options for controlling retry behavior.
Two important settings are:
Setting | Environment variable | Shared configuration key | Default |
|---|
Retry mode | AWS_RETRY_MODE | retry_mode | standard |
Maximum attempts | AWS_MAX_ATTEMPTS | max_attempts | 3 for most clients |
These settings can be configured through environment variables, the shared AWS configuration file, or SDK-specific client configuration.
The configuration precedence is generally:
Explicit client configuration in application code.
Environment variables.
Shared AWS configuration file.
SDK defaults.
This means a value configured directly in application code can override the same setting defined in an environment variable.
Configure Retry Settings Using Environment Variables
For Linux and macOS:
export AWS_RETRY_MODE=standard
export AWS_MAX_ATTEMPTS=3
For Windows PowerShell:
$env:AWS_RETRY_MODE = "standard"
$env:AWS_MAX_ATTEMPTS = "3"
These settings tell supported AWS SDKs to use standard retry mode with a maximum of three total attempts.
To disable automatic retries:
export AWS_MAX_ATTEMPTS=1
Disabling retries can be useful for specific testing scenarios, but it is generally not recommended for normal production workloads.
Configure Retry Settings in the AWS Shared Configuration File
You can also configure retry settings in the AWS shared configuration file.
On Linux and macOS, this file is generally located at:
~/.aws/config
Add the following configuration:
[default]
region = us-east-1
retry_mode = standard
max_attempts = 3
Applications using the default AWS profile can read these settings automatically.
If you use multiple AWS profiles, configure retry settings separately where required.
Implementing Retry Configuration in Python Using Boto3
Let's implement retry configuration using Boto3.
Boto3 provides a Config object that allows developers to configure retry behavior for individual AWS clients.
First, install the required package:
pip install boto3
Create a Python file named s3_retry_example.py.
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError, BotoCoreError
retry_config = Config(
retries={
"mode": "standard",
"total_max_attempts": 3
}
)
s3_client = boto3.client(
"s3",
region_name="us-east-1",
config=retry_config
)
def list_buckets():
try:
response = s3_client.list_buckets()
for bucket in response.get("Buckets", []):
print(bucket["Name"])
except ClientError as error:
print("AWS service error:", error)
except BotoCoreError as error:
print("AWS SDK error:", error)
if __name__ == "__main__":
list_buckets()
Let's understand the important parts.
The Config object defines the retry behavior for the S3 client.
The mode property selects standard retry behavior.
The total_max_attempts property specifies the maximum number of attempts, including the initial request.
This distinction is important in Boto3 because its retry configuration also supports a max_attempts setting with different counting semantics when supplied through client configuration.
Using total_max_attempts makes the intended behavior explicit.
The exception handling separates service errors from other SDK-related errors.
The SDK performs eligible retries internally before returning the final error to the application.
This keeps the application code simple while providing automatic recovery from temporary failures.
Configuring Retry Behavior in .NET Applications
The AWS SDK for .NET provides client-level configuration options for retry behavior.
Developers can configure retry settings when creating service clients instead of relying entirely on environment variables.
For example, consider an application that uses Amazon S3.
Install the AWS SDK package:
dotnet add package AWSSDK.S3
Create an S3 client with standard retry behavior:
using Amazon;
using Amazon.S3;
using Amazon.Runtime;
var config = new AmazonS3Config
{
RegionEndpoint = RegionEndpoint.USEast1,
RetryMode = RequestRetryMode.Standard,
MaxErrorRetry = 2
};
using var s3Client = new AmazonS3Client(config);
In this example:
RegionEndpoint specifies the AWS Region.
RetryMode selects standard retry behavior.
MaxErrorRetry specifies the number of additional retries after the initial request.
Therefore, MaxErrorRetry = 2 represents up to three total attempts when the SDK allows all configured retries.
This is an important distinction between the .NET SDK configuration and the shared AWS_MAX_ATTEMPTS setting.
The AWS SDK for .NET has its own version-specific configuration behavior. Verify the supported retry settings for the installed SDK version before relying on a particular default.
Understanding Retry Behavior Changes Across SDK Versions
AWS has been updating retry behavior to make it more consistent across SDKs.
Historically, some SDKs used standard retry mode by default, while others used legacy retry mode.
The updated behavior makes standard mode the default for additional SDKs and introduces consistent backoff timing and retry quota behavior.
The rollout became the default for most SDKs in November 2026, although the exact behavior depends on the SDK version.
This is particularly important for applications using Python, Java, Ruby, PHP, C++, and the AWS CLI because some of these tools previously used legacy retry behavior by default.
Developers upgrading AWS SDK packages should review the retry behavior changes instead of assuming that the old defaults remain unchanged.
Important Changes to Understand
The updated behavior includes:
Area | Updated behavior |
|---|
Standard retry mode | Recommended default |
Transient error base delay | 50 milliseconds |
Throttling error base delay | 1,000 milliseconds |
Retry quota | Standardized token bucket |
Default maximum attempts | 3 for most clients |
DynamoDB maximum attempts | 4 |
Legacy mode | Retained for backward compatibility where supported |
Some applications may notice that errors are returned sooner after an SDK upgrade.
This can happen when the previous SDK configuration allowed more attempts than the updated default.
Applications that depended on repeated retries to complete background operations should review their existing retry configuration before upgrading.
Test the updated behavior in a development or staging environment before applying changes to production workloads.
Best Practices for AWS SDK Retry Configuration
Retry configuration should be treated as part of application reliability engineering.
Simply increasing the number of retries does not always improve application reliability. Excessive retries can increase response times, consume connections, and create additional load during service disruptions.
The following practices help maintain predictable behavior.
Use Standard Mode for General Applications
Standard mode is suitable for most applications because it provides exponential backoff, jitter, and retry quota management.
It offers a reasonable balance between automatic recovery and resource protection.
Use adaptive mode only when your workload has a clear need for client-side rate limiting.
Set Maximum Attempts Based on Application Requirements
The default of three attempts is a reasonable starting point for many applications.
However, the appropriate value depends on the operation and its latency requirements.
For example, a background processing service may tolerate additional attempts, while a customer-facing API may need to return an error quickly.
Do not increase maximum attempts without considering the overall request deadline.
Consider the Total Request Timeout
Retries increase the total time required to complete an API operation.
Suppose an application allows a request to run for two seconds. If the SDK performs several retries with long backoff delays, the overall operation may exceed the application's timeout.
Coordinate SDK retry settings with:
HTTP request timeouts.
API gateway timeouts.
Application cancellation deadlines.
Background job execution limits.
User-facing response time requirements.
The SDK should not continue retrying after the application has already stopped waiting for the result.
Avoid Multiple Uncontrolled Retry Layers
One common production mistake is implementing retries at multiple levels without calculating their combined effect.
For example, an HTTP API might retry an operation three times, while the AWS SDK also performs three attempts for each operation.
This can result in up to nine AWS API attempts for a single logical operation.
If another layer also retries, the total number of requests can increase further.
Define a clear retry policy and understand which layer owns retry responsibility.
Use Idempotent Operations Where Possible
Retrying an operation is safer when repeating the same request does not create unintended side effects.
Read operations are generally easier to retry.
Write operations require additional care.
For example, if an application sends a payment-related request and the connection fails before receiving the response, it may not know whether the operation succeeded.
Sending the same request again could create duplicate processing.
Use idempotency keys, conditional writes, or other service-specific mechanisms where supported to prevent duplicate effects.
Monitor Retry Activity
Do not treat automatic retries as invisible behavior.
Monitor request latency, service exceptions, throttling responses, and retry counts where the SDK exposes them.
A sudden increase in retries can indicate:
AWS service throttling.
Insufficient resource capacity.
Network instability.
Incorrect application concurrency.
Changes in request traffic.
Monitoring retry activity helps identify problems before they become larger application reliability issues.
Common Mistakes When Configuring AWS Retries
Several mistakes can produce unexpected behavior when working with AWS SDK retry settings.
Mistake | Why it happens | Recommended solution |
|---|
Assuming three attempts means three retries | Initial requests are included in maximum attempts | Understand total attempts versus additional retries |
Increasing retries without timeout planning | Backoff increases total request duration | Coordinate retry and timeout settings |
Using adaptive mode for every client | Adaptive rate limiting is client-wide | Use it for suitable throttling-heavy workloads |
Retrying validation errors | Permanent errors are treated like temporary failures | Handle non-retryable errors directly |
Ignoring retry quota | Developers assume retries always continue | Account for retry quota exhaustion |
Using retries for duplicate-sensitive writes | A previous request may have succeeded despite a lost response | Implement idempotency controls |
Relying on old SDK defaults | Retry behavior changes between SDK versions | Review SDK release notes and configuration |
Understanding these mistakes helps developers avoid unnecessary retries and build more predictable applications.
Troubleshooting AWS SDK Retry Problems
When retry behavior does not match expectations, start by checking the SDK configuration and the actual error responses.
Application Returns Errors After Only One Attempt
Check whether retries have been disabled.
For example:
echo $AWS_MAX_ATTEMPTS
If the value is 1, the SDK is configured to perform only the initial request.
Also check whether client-level configuration overrides environment variables.
Application Retries More Than Expected
Review the configuration precedence.
An explicit client configuration can override values in environment variables and the shared AWS configuration file.
Also check whether your application has additional retry logic outside the SDK.
For example, an HTTP client, message-processing framework, or background job scheduler may independently retry failed operations.
Application Experiences Long Response Times
Repeated retries and backoff delays can increase the total time required to complete an operation.
Review:
If the application is customer-facing, consider whether the configured retry policy is compatible with the expected response time.
Requests Continue Failing During Throttling
Retries alone cannot solve insufficient service capacity.
If an application repeatedly receives throttling errors, investigate request patterns, service quotas, and resource capacity.
For DynamoDB, review table capacity, partition key distribution, and request concentration.
For other AWS services, identify the specific quota or rate limit being exceeded.
Consider reducing application concurrency or introducing request queues when appropriate.
Retry Quota Stops Additional Attempts
If standard mode stops retrying before reaching the configured maximum attempts, the retry quota may have been depleted.
This usually indicates sustained failures across requests handled by the client.
Investigate the underlying service errors and network conditions rather than simply increasing the maximum attempt count.
Advantages and Disadvantages of Automatic Retries
Automatic retries provide important reliability benefits, but they also introduce additional behavior that developers must understand.
Advantages
Automatic recovery: Temporary network and service failures can be handled without additional application code.
Improved reliability: Requests have additional opportunities to succeed when failures are temporary.
Reduced development effort: Developers do not need to implement retry handling for every AWS API operation.
Better traffic management: Exponential backoff and jitter help prevent synchronized retry requests.
Retry quota protection: Standard mode reduces unnecessary retry traffic during sustained failures.
Disadvantages
Increased latency: Each retry adds waiting time before the final result is returned.
Additional network traffic: Failed requests can generate multiple API calls.
Complex debugging: Automatic retries can make the original failure less visible without proper monitoring.
Duplicate operation risks: Some write operations require idempotency controls before they can be safely retried.
Configuration differences: SDK versions and service-specific defaults can affect the number of attempts and retry timing.
Developers should use automatic retries as one part of a broader reliability strategy rather than depending on them to solve every failure.
Summary
AWS SDKs provide built-in retry behavior to help applications recover from temporary service failures, network interruptions, and throttling errors.
Understanding the three retry modes is important when developing reliable AWS applications. Standard mode is recommended for most workloads because it combines exponential backoff, jitter, and retry quota management. Adaptive mode adds client-side rate limiting for suitable throttling-heavy workloads, while legacy mode remains available for backward compatibility in supported SDKs.
Developers should also understand that the default maximum attempts generally include the initial request. Most clients use three attempts, while DynamoDB and DynamoDB Streams use four under the updated standard retry behavior.
The most important production consideration is balancing retries with application timeouts, request deadlines, idempotency, and monitoring.
By configuring retry behavior carefully and reviewing SDK version changes, developers can build AWS-integrated applications that handle temporary failures more effectively without generating unnecessary network traffic or increasing application latency.
Join the conversation! Your thoughts help the community grow.