You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As @lennyburdette said in #1347 (comment), the current implementation of rate limiting is a global one, not a per client one. I think it's a good idea to have the latter in the Router as well.
Right now, if we'd like to implement it in a supergraph with N subgraphs, we'll have N implementations (potentially shared) to handle it. If it'd be possible to handle it in the Router, there's only one (or zero, if it'd be configurable and not a Rhai-script one).
A sliding window just like the one that is already there with some client differentiation would most likely cover almost all cases. AFAIK a client's IP and a header (or few) are the most common fingerprint.
Storing the information in memory is enough for us, but I can imagine it may be a problem for supergraphs with a massive number of users. In this case, it'd need external storage of some sort.
An idea of what the configuration could look like (heavily inspired by global_rate_limit):
traffic_shaping:
router: # Rules applied to requests from clients to the routerclient_rate_limit: # 10 requests per 5 seconds per IP.capacity: 10interval: 5sfingerprint:
- ipsubgraphs: # Rules applied to requests from the router to individual subgraphsproducts:
client_rate_limit: # 10 requests per 5 seconds per access key (header).capacity: 10interval: 5sfingerprint:
- header: authorizationusers:
client_rate_limit: # 10 requests per 5 seconds per (IP, access key) pair.capacity: 10interval: 5sfingerprint:
- ip
- header: authorization
The text was updated successfully, but these errors were encountered:
My use case for Router-based rate-limiting would definitely benefit from a shared rate-limiting state. Currently, as new Router instances are spun up in a multi-instance deployment, clients would effectively have their rate limit scale up as well. Enforcing the rate limit across all instances of the Router seems like it would be an ideal way to mitigate that problem.
As @lennyburdette said in #1347 (comment), the current implementation of rate limiting is a global one, not a per client one. I think it's a good idea to have the latter in the Router as well.
An idea of what the configuration could look like (heavily inspired by
global_rate_limit
):The text was updated successfully, but these errors were encountered: