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

Replace rate-limit code with exponential backoff #116

Open
uberbrady opened this issue Aug 19, 2023 · 0 comments
Open

Replace rate-limit code with exponential backoff #116

uberbrady opened this issue Aug 19, 2023 · 0 comments
Assignees

Comments

@uberbrady
Copy link
Member

So right now we have a lot of code throughout to handle backoff when rate-limits are exceeded - and it works very well, and I haven't heard a lot bad about it. But, I do have a few problems with it -

  1. The code repeats itself.
  2. The code generally retries only once.

According to the request docs here: https://requests.readthedocs.io/en/latest/user/advanced/#example-automatic-retries - there's a nice Retry system that we can use, which will automagically do exponential backoffs for us. I think we could use this by default, and then just remove the configuration options regarding backoff - just run as fast as you can, and back off when you have to. Maybe with an optional parameter about backoff duration settings?

The library https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.Retry which does those retries has a backoff_factor of 1 - which would give us sleeps of 1, 2, 4, 8 and so on, until we hit backoff_max (10 minutes maybe?) or total (10 retries maybe?). Could also make sense to have a far larger start backoff - 30 seconds, 10 seconds? - because in rate-limiting terms, 1, 2, 4, or 8 seconds isn't going to make a bit of difference.

@uberbrady uberbrady self-assigned this Aug 19, 2023
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

No branches or pull requests

1 participant