aspnetcore-redis-rate-limiting
aspnetcore-redis-rate-limiting copied to clipboard
Manual Replenishment
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.
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.