reverseproxy: Implement retry count, alternative to try_duration #4756
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.
Partially addresses some of the remaining points in #4245
This makes it possible to configure an amount of retries without having a particular time limit.
If both are configured, then the first of the two limits to be reached will cause retries to stop. For example if duration is 10s and retries is 5, then if 5 fast retries happen before 10s, it will stop. If 3 slow retries happen and 10s is reached, it will stop.
I was mulling over whether we should default
try_interval
to 250ms as well if a retries count is configured, I think it's okay if we don't; it's unlikely "CPU will spin" if we use a retry count because the count should almost always be low enough that it won't last very long. The user can always configure the interval if they want it.IMO this isn't a complete solution, there's still a usecase where you may want to actually continue retrying up to N amount of times even if you did configure a duration, in certain situations. I think for that we'd need to flesh out the
retry_match
stuff (which isn't currently supported in Caddyfile). We might also want a way to havehandle_response
trigger a retry according to a response matcher. And we may want a way to maketry_interval
do exponential backoff according to the number of tries (now that we've introduced that).