Skip to content

GitHub API rate limit handling #128

Open

Description

@tomellm

The GitHub API uses rate limiting to avoid clients from sending too many requests:
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28

When making calls to the Rest API you'll notice the following response headers:

X-Ratelimit-Limit: 5000
X-Ratelimit-Remaining: 4999
X-Ratelimit-Reset: 1712830913
X-Ratelimit-Resource: core
X-Ratelimit-Used: 1

Find a way to make our client code respect these rate limits. Other people probably already solved this problem in Spring Boot apps so make sure to spend some time to investigate existing solutions instead of diving directly in code.

Resilience4j optional. Maybe as a separate ticket.

Activity

  1. tomellm commented on May 21, 2024

    @tomellm
    ContributorAuthor

    consider how the rate limiting is tied to different tokes, meaning is it bound to the installation token or the app or whatever

  2. self-assigned this
    on May 21, 2024
  3. tomellm commented on May 21, 2024

    @tomellm
    ContributorAuthor

    Initial idea is the following. The number of requests we can do is relative to a specific time-frame this means we have a max req/min. Knowing what the limit req/min is I can now create a interceptor that will check if we are making more or less requests compared to the max req/min. If we do end up making more then the max what the interceptor will do is influence the rate at which cache eviction is being done. All cache eviction is on a schedule that is specified by each cache themselves but it is dependent on a multiplier which is the thing the interceptor changes. If the interceptor deems that there are too many requests being made then it will set this multiplier higher meaning less requests are being made. Otherwise it will drop it until reaching 1 where the cache eviction is being done on the default schedule. Some things to consider here are:

    • If the number of remaining requests drops too low have a scale according to which certain requests will be stopped entirely.
    • As mentioned above don't make the requesting happen at a faster speed then the default.
    • Maybe certain metrics should never be stopped.
  4. added 4 commits that reference this issue on May 27, 2024
  5. added a commit that references this issue on May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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