Skip to content
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

Include backoff period for a given rule #52

Closed
Brunomachadob opened this issue Apr 8, 2021 · 3 comments
Closed

Include backoff period for a given rule #52

Brunomachadob opened this issue Apr 8, 2021 · 3 comments

Comments

@Brunomachadob
Copy link

Brunomachadob commented Apr 8, 2021

Hey!

We have been using the library for a while (with redis) and we would like to complement it with a backoff period on top of the sliding window algorithm. We believe this would be a nice improvement on it by giving an extra punishment to whoever is misusing our systems.

"Tokens" will be used and added back like we are used to in a sliding window algorithm, but the change is:

  • If anyone crosses the limit, we will apply a backoff period of x amount of time blocking that key.

We could probably achieve that by populating the cache of a given key like time:precision:bo with the expiry of the backoff period for example, and simply return 1 early in the algorithm

This would be a backwards compatible change, probably on the RequestLimitRule adding the possibility to have the backoff only to the rules that configured it.

Do you find this interesting and would be willing to have it on the library? I can work on it and open the necessary PRs.
In case you agree, feel free to point me to any directions you may think it would be the best.

@Brunomachadob
Copy link
Author

Since this hasn't get any attention, we will close this, fork it and implement on our own.
Thanks

@ctoomey
Copy link
Contributor

ctoomey commented Apr 23, 2021

@Brunomachadob FYI we implemented the backoff/blackout period by using another rate limiter specifically for that, such that when they go over limit on the main limiter, we increment the count for that key in the blackout limiter, which has a limit of 1. No library code changes needed, and you can package that up as desired in your local code library.

@Brunomachadob
Copy link
Author

Brunomachadob commented Apr 23, 2021

Hey @ctoomey, yeah this is also an option and we considered it. But we would like to try to embed this into the Lua script used on Redis, as you can see on the linked PR I've opened. We will use that approach to have it everything within a single place and a single round trip to Redis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants