Skip to content
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

reverseproxy: Implement retry count, alternative to try_duration #4756

Merged
merged 4 commits into from Jul 13, 2022

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented May 1, 2022

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 have handle_response trigger a retry according to a response matcher. And we may want a way to make try_interval do exponential backoff according to the number of tries (now that we've introduced that).

@francislavoie francislavoie added the feature ⚙️ New feature or request label May 1, 2022
@francislavoie francislavoie added this to the v2.6.0 milestone May 1, 2022
@francislavoie francislavoie requested a review from mholt May 1, 2022 20:56
@francislavoie
Copy link
Member Author

Decided to spend a bit of time adding support for lb_retry_match in the Caddyfile. Pretty much stole the code from MatchNot. Pretty simple.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually LGTM for the most part. So retries end based on a "whichever comes first" kind of policy, if I understand correctly.

modules/caddyhttp/reverseproxy/caddyfile.go Outdated Show resolved Hide resolved
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slick refactor. That's probably much better as its own function. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants