marcosbarbero / spring-cloud-zuul-ratelimit

Rate limit auto-configure for Spring Cloud Netflix Zuul

Home Page:https://blog.marcosbarbero.com/spring-cloud-netflix-zuul-rate-limit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'Cooldown' period

innocode78 opened this issue · comments

Hi, I'm just wondering is there any feature like 'cooldown' period

For example when a particular user hit the limit, can we set the cooldown period to x second (after the user get 'Too Many Request' response)

I notice the refresh-interval is different from cooldown in that when the refresh-interval is 'constant' meaning when we start our service at minute 00:00 and let say we config the limit = 3 and refresh-interval = 60s, then within those minute till the next minute 01:00 the limit is 3 and no matter how much is used/consumed the limit will reset after 60 seconds since the service started, periodically
(the limit will be refreshed periodically at minute 01:00, minute 02:00, and so on that's why I mentioned it to be 'constant')

So my question is when when a specific user reached limit at say 00:30 (only 30 seconds left to next refresh-interval) is there any config for 'cooldown' period let say 1 hour or 10 minutes (different from the refresh-interval) so when the cooldown is 1 hour, then user can only retry after 1 hour since the last time the user got the 'Too Many Request' response

Is there such config for this kind of situation?

First, the rate limit algorithm depends on the implementation you chose.
For example, Bucket4J is using refill greediness, so limit of 3 for 60 seconds is the same as 1 for 20 seconds.

For the cooldown, I don't see a way to configure it currently, but can be an interesting addition.
Maybe configuring multiple limits with different intervals (and without refill greediness) will work for you:

  • 3 for 60 seconds
  • 15 for 600 seconds
  • 100 for 6000 seconds

So if someone is using many resources in a short time it will be limited by the longer ones

Hi @lchayoun ,

Thank you for the information.

I have my own implementation on how to manage cooldown period

Cheers.