Add ability to limit both total dur and num retries#24
Merged
Conversation
azanin
approved these changes
May 13, 2025
suryapandian
approved these changes
May 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The previous
build_with_total_retry_duration_and_max_retriesfunction used a calculated max. retries.This PR adds a function to specify the max. retries, along with a max. total duration.
It also renames
build_with_total_retry_duration_and_max_retriestobuild_with_total_retry_duration_and_limit_retrieswhich I think fits a bit better. This is a breaking change.Rationale
We often have latency targets we need to meet, and we shouldn't continue retrying beyond that target.
We also often want to limit the number of retries to avoid overloading the system we're calling.
In other words, we might want to:
Consider a retry policy like the following:
Our maximum intervals (i.e. without jitter) would be:
For a total of 200ms. In this case, the max. total duration would kick in and prevent the third retry.
With jitter, however, our minimum intervals would be:
For a total of 75ms. In this case, we would retry 3 times.
Other notes
BoundedJitterI believe the first retry will always be the same duration (no jitter). This seems like a problem.