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
Rate Limiting works incorrectly if PeriodTimespan value is greater than Period #1590
Comments
Hi Sergii! Do not you mind if we collaborate on the issue description first? |
Check the issue Title please! |
Sergii, |
I think yes. But give me a little time, please, to dive into the context. Also I apologize for inacurate title. |
So, bug description has been changed and updated. |
@sergio-str Hi Sergii! |
@sergio-str Sergii I would like your checking this bug for the latest build/version which is 19.0.2 and .NET 7. Do not you mind if I change Ocelot Version to 19.0.2 in Specifications paragraph? |
Also, is it possible to configure RateLimiting globally? Looks like the limits work only when specified at Route level. It's inconvenient to configure Limits for large number of routes. |
Hi Mithun! |
Expected Behavior
Rate Limiting works as documented for such parameter values:
Period: 1 second
PeriodTimeSpan: 30 seconds
Limit: 100
Scenario:
Request flow, 10-20 requests per sec, should be allowed.
Status: not equal to 429
Actual Behavior / Motivation for New Feature
With the same parameter values from Expected Behavior Ocelot returns status 429 aka "Rate limit exceeded".
It seems this issue caused by code in RateLimitCore.cs lines 35-43
Ocelot increments request counter if request has been received in interval [FirstRequestTime : FirstRequestTime + PeriodTimeSpan]
According to the documentation counter should be incremented if request is in interval [FirstRequestTime : FirstRequestTime + Period].
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: