Skip to content

Add a Redis-backed token bucket RateLimiter implementation #41861

Open
@halter73

Description

@halter73

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.

@BrennanConroy @wtgodbe

Additional context

Customers are asking for this.

Metadata

Metadata

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-rate-limitWork related to use of rate limit primitives

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions