javav2/example_code/dynamodb/adaptive_retry_docs/concepts.md
AWS Java SDK's AdaptiveRetryStrategy is a specialized retry strategy designed for use cases with high resource constraints. It includes all features of the standard retry strategy plus a client-side rate limiter that measures throttled vs non-throttled requests to minimize throttling errors.
⚠️ Important: AdaptiveRetryStrategy assumes the client works against a single resource (e.g., one DynamoDB table or one S3 bucket). AWS recommends StandardRetryStrategy for most use cases.
Traditional retry policies use fixed algorithms with predetermined backoff strategies:
Limitations:
Adaptive retry includes all features of the standard strategy and adds:
Benefits:
⚠️ Single Resource Assumption: If you use a single client for multiple resources, throttling or outages with one resource will cause increased latency and failures for all other resources accessed by that client.
Adaptive retry includes built-in client-side rate limiting to prevent overwhelming services during degradation.
Each client maintains a token bucket that provides a mechanism to stop retries when a large percentage of requests are failing and retries are unsuccessful.
The strategy measures the rate of throttled requests compared to non-throttled requests to determine when to slow down request rates.
Different retry strategies for different error types:
Always test that your AdaptiveRetryStrategy configuration compiles correctly:
@Test
public void testAdaptiveRetryStrategyCompilation() {
// Test basic configuration
AdaptiveRetryStrategy strategy = AdaptiveRetryStrategy.builder()
.maxAttempts(3)
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(strategy)
.build())
.build();
assertNotNull(client);
client.close();
}
@Test
public void testRetryModeConfiguration() {
// Test RetryMode approach
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
.build())
.build();
assertNotNull(client);
client.close();
}
Monitor retry behavior in your application logs to ensure the adaptive strategy is working as expected:
When implementing AdaptiveRetryStrategy, use the correct AWS SDK v2 API:
// CORRECT - Basic AdaptiveRetryStrategy configuration
AdaptiveRetryStrategy adaptiveRetryStrategy = AdaptiveRetryStrategy.builder()
.maxAttempts(3)
.backoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofMillis(100), // base delay
Duration.ofSeconds(20) // max delay
))
.throttlingBackoffStrategy(BackoffStrategy.exponentialDelay(
Duration.ofSeconds(1), // base delay for throttling
Duration.ofSeconds(20) // max delay for throttling
))
// Note: circuitBreakerEnabled() method doesn't exist - circuit breaking is built-in
.build();
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(adaptiveRetryStrategy) // Use retryStrategy(), not retryPolicy()
.build())
.build();
For basic adaptive retry behavior, use RetryMode:
// CORRECT - Simplest adaptive retry configuration
DynamoDbClient client = DynamoDbClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.retryStrategy(software.amazon.awssdk.core.retry.RetryMode.ADAPTIVE)
.build())
.build();
software.amazon.awssdk.retries.AdaptiveRetryStrategy (not core.retry)AdaptiveRetryStrategy.builder() (not RetryPolicy.builder()).retryStrategy() (not .retryPolicy()).circuitBreakerEnabled() method)Now that you understand the concepts, proceed to:
This conceptual guide is based on official AWS SDK for Java 2.x documentation:
AWS SDK for Java 2.x Developer Guide - Configure retry behavior
AWS Documentation
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/retry-strategy.html
Retrieved: August 18, 2025
AWS SDK for Java 2.x API Reference - AdaptiveRetryStrategy
AWS SDK API Documentation
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/retries/AdaptiveRetryStrategy.html
Retrieved: August 18, 2025
Citations: