aspnetcore-redis-rate-limiting icon indicating copy to clipboard operation
aspnetcore-redis-rate-limiting copied to clipboard

Manual Replenishment

Open gorillapower opened this issue 1 year ago • 1 comments

Are there any plans to implement a ReplenishmentRatelimiter version of the current Redis Ratelimiters?

In my case, im trying to prevent 429s on a downstream api endpoint, but it looks like due to network latency and/or timing issues, this cannot be guaranteed.

An alternative is to manually control the replenishment ourselves to guarantee that the request has started/ended before we replenish the ratelimiter.

gorillapower avatar Dec 02 '24 11:12 gorillapower

Ive added a RedisReplenishmentSlidingWindowLimiter implementation in the following repo https://github.com/gorillapower/aspnetcore-redis-rate-limiting.

Basically, im just keeping track of two counters. One tracks the ratelimit window, as was before, the other tracks the replenishment tokens, which can only be replenished manually by calling the TryReplenish() method.

gorillapower avatar Dec 02 '24 14:12 gorillapower