Skip to content

Is there a way to make this rate limiter use rolling window instead of fixed window algorithm? #126

Answered by animir
caveen1999 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @caveen1999,

There is no easy way to do that.

However, if you are curious, there is interesting way to implement it using rate-limiter-flexible. Actions may consume points by key ${ip}-${unixtimeSeconds} with expiration equals to rolling window duration, e.g. 10 seconds. Every moment, consumed points for last 10 seconds can be got from store and summarised to allow or prohibit an action.
This would be much slower than rolling-rate-limiter though.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@caveen1999
Comment options

Answer selected by animir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants