Description
Is your feature request related to a problem? Please describe the problem.
In the runtime repo, we have included a bunch of built-in, in-memory RateLimiter
implementations like ConcurrencyLimiter
, FixedWindowRateLimiter
, SlidingWindowRateLimiter
and TokenBucketRateLimiter
. It would be nice to add a rate limiter that works across multiple hosts in a distributed environment. In the past, for things like our RedisCache
IDistributedCache
implementation, we've used StackExchange.Redis to implement a solution in the aspnetcore repo for a runtime abstraction. I think we should do the same things for this.
Describe the solution you'd like
I think we should implement a token bucket RateLimiter
based on Redis using StackExchange.Redis that can be used in distributed environments. I imagine the options for this rate limiter will be a combination of what's in TokenBucketRateLimiterOptions and RedisCacheOptions.
We might want to make it easier to reuse existing IConnectionMultiplexer
since there will likely be multiple instances by default. Another way to avoid unnecessary Redis connections might be to implement PartitionedRateLimiter<string>
instead of RateLimiter
.
Additional context
Customers are asking for this.