-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: add fixed_window bucket option #79
Conversation
5aab976
to
1af1cb4
Compare
…val in fixed window
5ddd69d
to
8e6db47
Compare
172c024
to
c295eba
Compare
c71d2ef
to
5115d42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't really review all, will continue tomorrow.
README.md
Outdated
### Use of fixed window on Take and TakeElevated | ||
If you want to use fixed window on Take or TakeElevated, you can do so by setting the `fixed_window` property in the bucket configuration to `true` (default `false`). This will refill the bucket at the specified interval instead of granular. | ||
|
||
On top of that, you can use the `fixed_window` property in the `configOverride` parameter to safely activate/deactivate the new fixed_window algorithm from the client on-demand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the benefit or use case of being able to enable this on demand? What would happen if clients are doing requests with fixed window on and off all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the benefit or use case of being able to enable this on demand?
We would be able to do a controlled rollout. Nowadays everyone is using sliding window; we want to introduce the fixed window algorithm but wanna make sure the transition is controlled. If something doesn't work as expected sending the fixed_window=false (feature flag) param will fallback to sliding window
What would happen if clients are doing requests with fixed window on and off all the time?
That shouldn't happen. It's the same risk for clients calling take with and without overrides.
…culated for fixed window in takeeleavated
bd5e133
to
d9aea0c
Compare
dff9633
to
6e050bb
Compare
6e050bb
to
c67091a
Compare
README.md
Outdated
|
||
If you want to use fixed window algorithm on Take or TakeElevated, you can do so by setting the `fixed_window` property in the bucket configuration to `true` (default `false`). This will refill the bucket at the specified interval instead of granular. | ||
|
||
On top of that, you can use the `fixed_window` property in the `configOverride` parameter to safely activate/deactivate the new fixed_window algorithm from the client on-demand. This parameter acts as a feature flag to safely deploy the change to produciton. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
On top of that, you can use the `fixed_window` property in the `configOverride` parameter to safely activate/deactivate the new fixed_window algorithm from the client on-demand. This parameter acts as a feature flag to safely deploy the change to produciton. | |
On top of that, you can use the `fixed_window` property in the `configOverride` parameter to safely activate/deactivate the new fixed_window algorithm from the client on-demand. This parameter acts as a feature flag to safely deploy the change to production. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Original PR by Panga
Add
fixed_window
bucket option when enabled refill at specified interval instead of granular.fixed_window
optional parameter in the take and takeElevated methods. The parameter takes precedence over the bucket option, making it easier to activate/deactivate using a feature flag on the client side.Used for enforcing a rate limit policy that does not allow allow request rate to go over a the size in a given interval.
Examples
Default behavior
Result: Refill 1 token each 1 millisecond.
New fixed_window: true
Result: Refill 1000 tokens each 1000 milliseconds.