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

Global/application rate limits applied twice if per route rate limits are also specified #108

Closed
tkrajca opened this issue Nov 15, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@tkrajca
Copy link

tkrajca commented Nov 15, 2017

I believe that when application rate limits are specified and a per endpoint rate limit is specified, then the application rate limits are applied twice - once in the before_request() hook and second in the decorated route, i.e. one request is counted as if it was 2.

Example:

app = Flask(__name__)
limiter = Limiter(app, application_limits=["600 per minute"])

@app.route("/")
@limiter.limit("300 per minute")
def index():
    return "test"

@app.route("/2")
def index2():
    return "test2"

Every request to / will be counted as two requests towards the application limit of 600 per minute and as one request towards the per route limit of 300 per minute.

With /2, everything works as expected in that one request counts as one request towards the application limit of 600 per minute.

Looking at the code, I think this is handled for default_limits but not for application_limits. I might be able to have a go at a patch but not sure when.

@alisaifee alisaifee added the bug label Nov 24, 2017
@alisaifee alisaifee self-assigned this Nov 24, 2017
@alisaifee alisaifee added this to the 1.1.0 milestone Nov 24, 2017
alisaifee added a commit that referenced this issue Dec 1, 2017
@alisaifee alisaifee modified the milestones: 1.1.0, 1.0.1 Dec 1, 2017
@alisaifee
Copy link
Owner

Sorry for the delay in getting this out - it has been fixed and released in 1.0.1

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

No branches or pull requests

2 participants