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

Add retry mechanism with backoff #1494

Merged
merged 1 commit into from
Aug 18, 2021
Merged

Add retry mechanism with backoff #1494

merged 1 commit into from
Aug 18, 2021

Conversation

nbraun-amazon
Copy link
Contributor

@adamserafini
Copy link

adamserafini commented Jun 18, 2021

My 2 cents: obviously interested to hear what the core maintainers think, but I don't think this belongs in redis-py library. IMO this breaks the 'do one thing and one thing well' principal.

I would rather see 'back-off and retry' as a standalone library I can use for any network call instead of repeatedly bundling it with redis-py and any other library that might need to retry.

For example, here is an example of a standalone library covering this exact same functionality which I can already use with redis-py (or anything else) if I choose to do so: https://pypi.org/project/retry/

I have no particular say on the matter (this is just a drive by comment) but I would vote to close this PR without merging it.

@nbraun-amazon
Copy link
Contributor Author

Thanks for your comment. This is a small change, and it has a specific API with callbacks on failures as well, which the library you mentioned does not support, as far as I can tell. Moreover, I don't think the retry with backoff mechanisms warrants adding an external dependency to redis-py.

@adamserafini
Copy link

Just to clarify, I don’t suggest to add external dependency to redis-py for retry functionality.

I am suggesting that ‘retry’ is a concern that can remain outside of this library, we do not need to build it into redis-py.

@nbraun-amazon nbraun-amazon force-pushed the master branch 3 times, most recently from c0337b1 to 333480d Compare July 1, 2021 17:58
@abrookins
Copy link
Contributor

Not a maintainer, but I like this PR. This allows a uniform retry policy that applies to all command executions, without requiring someone to figure out how to hook in an external retry library. Moreover, this allows configuring full jitter backoff. From my view, this PR makes redis-py more reliable for more people.

redis/client.py Outdated Show resolved Hide resolved
@nbraun-amazon
Copy link
Contributor Author

Ping on this PR @andymccurdy. Please let me know your feedback. Thanks!

@chayim
Copy link
Contributor

chayim commented Jul 29, 2021

First @nbraun-amazon I love the approach - it's elegant and easy to understand. Things are tidy, nicely documented, and high quality. It also solves my personal, #1 issue.

I'm torn. I really love do one thing and do it well. It's the reason I love Unix. At the same time, it seems like python libraries in general as they mature move from that model to an extended version of it. I'd vote for inclusion. If anything, toggling retry to default False and friends, solve these concerns. I'm 👍 @andymccurdy ?

redis/client.py Show resolved Hide resolved
chayim
chayim previously requested changes Aug 5, 2021
Copy link
Contributor

@chayim chayim left a comment

Choose a reason for hiding this comment

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

Can we change the comment format to docstrings for classes and functions when not please (i.e EqualJitteBackoff, DecorrelatedJitterBackoff..) Similarly, can we docstring functions like reset and compute.

Overall, I'm a proponent of merging - but I'd like to hear from @andymccurdy

* Add the Backoff abstract base class with four backoff strategies
  based on https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
* Add the Retry class which is constructed from
  a backoff strategy and a maximum number of retries, through the `retry` parameter
@nbraun-amazon
Copy link
Contributor Author

Can we change the comment format to docstrings for classes and functions when not please (i.e EqualJitteBackoff, DecorrelatedJitterBackoff..) Similarly, can we docstring functions like reset and compute.

Overall, I'm a proponent of merging - but I'd like to hear from @andymccurdy

I addressed your comments. Thanks for your feedback.

@abrookins
Copy link
Contributor

I'm in favor of merging this PR. It creates a more reliable, batteries-included client out of the box, which I like. It does "one thing," being Redis connection and command management, better than before, IMO.

@chayim chayim dismissed their stale review August 17, 2021 18:58

Changes implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

redis_listen_with_retries: adjusting back-off for kubernetes
4 participants