Skip to content

Replace rate-limit code with exponential backoff #116

@uberbrady

Description

@uberbrady

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions