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

Rate Limit Handling #2787

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

thomhurst
Copy link
Contributor

No description provided.

@thomhurst
Copy link
Contributor Author

@nickfloyd This could be a way of handling rate limits? What do you think? Just thinking out loud here.


// Could rate limit refreshes be up to an hour in the future?
// Should we conditionally retry only if it's a short period in the future
if (timeToWait < TimeSpan.FromSeconds(30))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite a long time to wait in the case of microservices. Places where I use Octokit would have a request timeout in the region of a few seconds at most, so this would be redundant in those cases as the CancellationToken would always fire and prevent another attempt ever happening while masking the HTTP request exception from the 403(429?) with a timeout-related exception instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I do agree. From the documentation, unless I'm wrong, it sounded like rate limits reset hourly. In which case this functionality might not be particularly useful as it would very rarely be hit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah from my experience, once you hit a limit then you just have to wait, unless it's a secondary rate-limit - those reset much sooner (I don't know how often though, I think it's the order of minutes).

@SlyckLizzie
Copy link
Contributor

I have implemented a leaky bucket type API filter in my own code. Not sure how I would port it over to here but the idea is that you have x number of calls that can be used in y time. Only allow one call per z milliseconds. That way you never really run out and it seems to adhere to the rate AND abuse limits.

Reading
https://dzone.com/articles/detailed-explanation-of-guava-ratelimiters-throttl#:~:text=The%20leaky%20bucket%20limits%20the%20constant%20outflow%20rate%2C,is%20always%20stable%2C%20regardless%20of%20the%20inflow%20rate.

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

Successfully merging this pull request may close these issues.

None yet

4 participants