-
Notifications
You must be signed in to change notification settings - Fork 37
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
RateLimit: minSpacing violations count towards window limit #973
Comments
Looking at the impl, this is clear: Lines 39 to 44 in 18ee406
Even if the outcome is to deny invocation based on the minSpacing, we still decrement currentPermits |
And guarded in SmoothWindow: Lines 45 to 47 in 18ee406
This should fix it! |
This actually is documented in the javadoc of
Fixed and rolling strategies are fundamentally very different from the smooth strategy. The first two enforce an invocation count in given time, while the third enforces invocation rate (computed from the limit and time window length). |
I'm adding that paragraph to the reference guide for rate limit as well: #975 Also, one option you have is to specify the rate limit (if you want fixed or rolling) not as 6 per hour, but 1 per 10 minutes. |
I have been experimenting with
@RateLimit
for an app contact form: I send an email to myself when a new contact is submitted, but want to rate limit so people can't spam me. So I am working with a larger window than normal (6 per hour) so this is observableI have noticed that RateLimit will not always reach the 'value' of invocations in the window, if the minSpacing is violated. So for example, if I have 6 invocations per hour, and
minSpacing = 1, minSpacingUnit = SECONDS
, and I submit 6 requests in 1 second, only 1 request makes it through. That is expected. But further spaced out requests within the hour are not invoked. So minSpacing violations count towards the overall window limit. This isn't really what I expected, and I think it's probably not the intention (the docs are not clear on this scenario)The text was updated successfully, but these errors were encountered: