Skip to content
Ollie Jennings edited this page Sep 9, 2020 · 1 revision
What happens when l call .execute?
  1. We process the request without using any rate-limiter (at this point they have no been setup).
  2. On the response (2xx or 4xx) we take the rate-limit headers and setup our rate-limiters
  3. We return the response if 2xx
  4. If a 429 is encountered, we then pause for a duration sepecified in the Retry-After header, and then execute the request using the rate-limiters setup
What are the rate-limiters?
  • The rate-limiters are Bottleneck instances
  • Each region or method can have multiple rate-limiters (with 1 acting as main)
  • Reason behind multiple rate-limiters is because Riot often returns multiple rate limits on an API, e.g. 1:120,9000:100.
  • Each rate-limiter can be chained to another, so each method rate-limiter is chained to its respecitvie region rate-limiter, respecting the limits of both.
How do you handle 429 responses?

If a 429 response is received, we automatically retry the request depending on a few scenarios:

  1. Determine the rate limit type we hit via the X-Rate-Limit-Type header, was it application, method or service?

    • This determines which rate-limiter should be incharge of retrying the request.
    • Allows method rate-limiters to not block the application rate-limiter if the limit type was method
  2. Get the duration we should backoff until retrying the same request from the Retry-After header.

    • If this is not present (as can be on some 429 responses), we then retry after the default 5 secs duration.
  3. Schedule the retry, and update all affected rate-limiters with the latest rate limits returned in the 429 response

Clone this wiki locally