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

Add period for rate limiter middleware #6055

Merged
merged 5 commits into from Jan 8, 2020
Merged

Conversation

mpl
Copy link
Collaborator

@mpl mpl commented Dec 18, 2019

What does this PR do?

We're getting some user feedback that they would like to be able to specify a rate limit lower than 1 request per second.
One possibility would have been to change the "average" field to a float (e.g. 6 requests / minute would have been average=0.1).
However, that would break the configuration (among other things) as TOML will not decode a value that looks like an int (no decimal point specified) into a Go float64.

Therefore, this PR (re-)introduces the notion of a period, that allows one to (optionally) specify the duration for which the given average applies.
The default value for the period is 1 second, which means if no period is specified, the meaning of the average does not change compared with before this change (it is still in requests/s).

Motivation

Fixes #5918

More

  • Added/updated tests
  • Added/updated documentation

@mpl mpl added kind/enhancement a new or improved feature. area/middleware labels Dec 18, 2019
@mpl mpl added this to To review in v2 via automation Dec 18, 2019
@ldez ldez changed the title Reintroduce period for rate limiter middleware Add period for rate limiter middleware Dec 18, 2019
@ldez ldez added this to the next milestone Dec 18, 2019
script/test-unit Outdated Show resolved Hide resolved
@mpl mpl closed this Jan 2, 2020
@mpl mpl deleted the ratelimit branch January 2, 2020 16:07
v2 automation moved this from To review to Done Jan 2, 2020
@mpl mpl restored the ratelimit branch January 2, 2020 16:08
@mpl
Copy link
Collaborator Author

mpl commented Jan 2, 2020

yay I deleted my branch while doing some cleanup

@mpl mpl reopened this Jan 2, 2020
Copy link
Contributor

@dtomcej dtomcej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
:shipit:

Copy link
Collaborator

@SantoDE SantoDE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@ldez ldez self-requested a review January 8, 2020 09:28
mpl and others added 4 commits January 8, 2020 10:58
We're getting some user feedback that they would like to be able to specify a
rate limit lower than 1 request per second. One possibility would have been to
change the "average" field to a float (e.g. 6 requests / minute would have been
average=0.1). However, that would break the configuration (among other things)
as TOML will not decode a value that looks like an int (no decimal point
specified) into a Go float64.

Therefore, this PR (re-)introduces the notion of a period, that allows one to
(optionally) specify the duration for which the given average applies. The
default value for the period is 1 second, which means if no period is specified,
the meaning of the average does not change compared with before this change (it
is still in requests/s).

Fixes traefik#5918
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
v2
Done
Development

Successfully merging this pull request may close these issues.

Specify period for rate limiting on v2
5 participants