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

Rolling window limits? #32

Open
eugenemiretsky opened this issue Jan 15, 2018 · 10 comments
Open

Rolling window limits? #32

eugenemiretsky opened this issue Jan 15, 2018 · 10 comments

Comments

@eugenemiretsky
Copy link

Hi!
Does the library support rolling windows limits?
For example, if my limit is 60 per hour, there are 2 ways to go about it

  1. If the user hits the limit, she has to wait for 1 hour before the limit resets. Making even one call during the one hour time period will extend the limit by another hour. For example: if I made 60 calls in 1 hour, and then make one call in 1:59, I will be rate limited, and will have to wait for until 2:59 for the limit it reset )
  2. The limits get incremented as the time window slides, to always count only the events in the last hour. For example: if I made 60 calls in 1 hour (5 of which were in the first minute), and 1:01 I am allowed to make 5 more calls.

Based on reading the code, I think only 1 is supported, but just want to make sure

@mattklein123
Copy link
Member

Windowed limits are not currently supported.

@andrascz
Copy link

Would you be interested in something like https://github.com/brandur/redis-cell?
This practically shifts the rate limit algorithm implementation from the service to Redis, but I think could be implemented with minimal effort.

@mattklein123
Copy link
Member

@andrascz it might be interesting to support something like that, though I think to be useful we would need to support those commands with whatever sharding/cluster system is being used. A single redis host is not going to scale in most deployments.

@andrascz
Copy link

I am not 100% sure as I did not try it on cluster, but based on brandur/redis-cell#30, either it is already working or needs minimal tweaks.

@walbertus
Copy link
Contributor

@mattklein123 If the redis-cell support sentinel and cluster setup, will envoyproxy/ratelimit use it? Or you are inclined toward internal code implementation?

@mattklein123
Copy link
Member

@mattklein123 If the redis-cell support sentinel and cluster setup, will envoyproxy/ratelimit use it?

Can you describe more what you are proposing?

@walbertus
Copy link
Contributor

There are two possible approaches to support rolling window limits:

  1. Use redis-cell then create a new cache impl that uses redis-cell commands
  2. Implement rolling window limit logic in new cache impl with basic Redis commands

The first approach would create a dependency on redis-cell module and shifting implementation to Redis.
This is a tradeoff between creating dependency vs maintaining implementation, which approach does the maintainer prefer?

@mattklein123
Copy link
Member

In general I think (2) is better, but I have no objection to having an option that requires redis-cell as long as it is opt-in.

@exagil
Copy link

exagil commented Dec 10, 2021

Has there been a decision on an algorithm for rolling window rate limiting yet?

@ysawa0
Copy link
Member

ysawa0 commented Dec 10, 2021

I don't think there was a decision made to strictly use a certain algorithm. There was work being done in #243 and #193 to implement rolling window but it's gone stale unfortunately.

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

No branches or pull requests

6 participants