-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Redis-backed token bucket RateLimiter implementation #41861
Comments
Thanks for contacting us. We're moving this issue to the |
Worth considering this scenario when working on this too: #41861 |
Is this now moved to .Net 9 or what is the current status? |
@mgravell Does this align with the Redis work you're planning? |
BTW, I have proof-of-concept implementations here, which might serve as inspiration (or example of what not to do - either way is fine to me): https://github.com/ReubenBond/DistributedRateLimiting.Redis/tree/main/DistributedRateLimiting.Redis |
@amcasey this is certainly a topic I've discussed with Aditya, but this isn't what I'm focusing on right now; I have thoughts on it, in particular around avoiding latency overheads via broadcast, but that also depends on how strict we need to be ("N per T" is very different depending on whether there's an implied "give-or-take" hand-wave in there), but I haven't actively spiked anything. I'll take a look at Reuben's braindump. (after eyeball) @ReubenBond the approach itself looks fine (I think it still pays latency for the core acquire, but maybe that's OK in most scenarios), but purely meant constructively: there are a few things in that impl that can be improved, in particular around redis compatibility re cluster routing and side-effect vs verbatim script replication; I suspect you tested on a standalone (non-cluster) newish server, which would have hidden some landmines from you - but: they exist. Happy to take a moment to discuss these at your convenience, if you want to learn a little more redis nuance. |
Is there any progress of this feature? |
Hey @md-redwan-hossain, we haven't worked more on this since the last update. We're almost certainly not going to have time for this in the .NET 9 timeframe. We're definitely aware of the need for a better distributed story for rate limiting. |
Any chance of adding an SQL Database (Oracle) as distributed cache for rate limiting? |
If/when we add something here, there would absolutely be some open abstraction that arbitrary backend implementations could provide, in the same way as we do today for |
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 likeConcurrencyLimiter
,FixedWindowRateLimiter
,SlidingWindowRateLimiter
andTokenBucketRateLimiter
. It would be nice to add a rate limiter that works across multiple hosts in a distributed environment. In the past, for things like ourRedisCache
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 implementPartitionedRateLimiter<string>
instead ofRateLimiter
.@BrennanConroy @wtgodbe
Additional context
Customers are asking for this.
The text was updated successfully, but these errors were encountered: