-
Notifications
You must be signed in to change notification settings - Fork 915
Add adaptive retry strategy #3957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add adaptive retry strategy #3957
Conversation
core/retries/src/main/java/software/amazon/awssdk/retries/AdaptiveRetryStrategy.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Outdated
Show resolved
Hide resolved
core/retries/src/main/java/software/amazon/awssdk/retries/DefaultRetryStrategy.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Outdated
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterAcquireResponse.java
Outdated
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterTokenBucketStore.java
Outdated
Show resolved
Hide resolved
...est/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterTokenBucketTest.java
Show resolved
Hide resolved
...main/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterUpdateResponse.java
Outdated
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterTokenBucketStore.java
Outdated
Show resolved
Hide resolved
core/retries/src/main/java/software/amazon/awssdk/retries/DefaultRetryStrategy.java
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Outdated
Show resolved
Hide resolved
...retries/src/main/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyImpl.java
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterAcquireResponse.java
Show resolved
Hide resolved
...ries/src/main/java/software/amazon/awssdk/retries/internal/ratelimiter/RateLimiterClock.java
Outdated
Show resolved
Hide resolved
/** | ||
* Updates the estimated send rate after a successful response. | ||
*/ | ||
public RateLimiterUpdateResponse updateRateAfterSuccess() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the implementation at https://github.com/aws/aws-sdk-java-v2/blob/master/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/retry/RateLimitingTokenBucket.java uses commonly accepted API naming conventions, such as refill() as direct API of the bucket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I have seen that as well. This class encapsulates that logic and exposes a better naming which makes the reading of the code using it easier to understand.
} | ||
} | ||
|
||
private static class TransientState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be really helpful for readability if we could have APIs related to tokenBucket in RateLimiterTokenBucket class and other methods in a Helper class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean by "other methods", all the code contained in this class is related to the rate limiter token bucket. Can you please point me which methods you think should go into a different class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to suggest that we limit the responsibilities of the RateLimiterTokenBucket class to acquiring and refilling tokens, and leave other functionalities like refilling based on success, exception, or throttle exception to be handled by a separate wrapping or helper class. This way, the RateLimiterTokenBucket class can focus solely on acquiring and refilling tokens, while the helper class can handle scenarios where tokens need to be acquired or refilled based on success or failure.
That we can limit RateLimiterTokenBucket responsibility to just acquire and refill and the helper class will acquire/refill based on the success failure scenarios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other methods are methods that updates the tokens based on error/success criteria like updateRateAfterThrottling etc
}); | ||
} | ||
|
||
private <T> StateUpdate<T> updateState(Function<TransientState, T> mutator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for repeating the reference of RateLimitingTokenBucket but the java docs followed in that class is very helpful , can we add similar java docs here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can add something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some doc comments when appropriate, but I did not add any of the java docs that shows the pseudo-code of the method being implemented such as:
/**
* <pre>
* _CUBICThrottle(rate_to_use)
* calculated_rate = rate_to_use * BETA
* return calculated_rate
* </pre>
*/
// Package private for testing
double cubicThrottle(double rateToUse) {
double calculatedRate = rateToUse * BETA;
return calculatedRate;
}
Since I think those actually makes the reading harder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay ,It would be great if the PR included a brief description of the modifications made to the classes, specifically in terms of their relationships.
SonarCloud Quality Gate failed. |
This new module includes the interfaces and classes that will be used to implement the new retry logic within the SDK.
Motivation and Context
As part of the Smithy Reference Architecture this change adds the new default adaptive strategy.
Modifications
No modifications to existing code were made. We will make those changes in follow up pull requests.
Testing
AdaptiveRetryStrategy
Screenshots (if appropriate)
N/A
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License