-
Notifications
You must be signed in to change notification settings - Fork 6
FAQ
Ollie Jennings edited this page Sep 9, 2020
·
1 revision
What happens when l call .execute?
- We process the request without using any rate-limiter (at this point they have no been setup).
- On the response (2xx or 4xx) we take the rate-limit headers and setup our rate-limiters
- We return the response if 2xx
- If a
429
is encountered, we then pause for a duration sepecified in theRetry-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:
-
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
-
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.
- If this is not present (as can be on some 429 responses), we then retry after the default
-
Schedule the retry, and update all affected rate-limiters with the latest rate limits returned in the 429 response