-
Notifications
You must be signed in to change notification settings - Fork 79
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
Multiple throttle options #149
Comments
You should be able to do something like: sidekiq_throttled(
threshold: [
{ limit: 5, period: 5.minutes, key_suffix: "minutely" },
{ limit: 100, period: 1.hour, key_suffix: "hourly" },
{ limit: 1000, period: 1.day, key_suffix: "daily" },
]
) |
Does not seem to work for me. Can you confirm the settings above are correctly? |
@apetrov88 What's your sidekiq and sidekiq-throttled version? |
I can confirm that this does not work with:
In the Sidekiq Admin, the jobs that I attempt to throttle with an array of throttle options, both using string values for When I replace the array of throttle options with a single hash of throttle options, the job reappears and is throttled as expected. I have tried: Will not appear on sidekiq UI, no throttling happens: sidekiq_throttle(
threshold: [
{ limit: 5, period: 5.minutes, key_suffix: ->(job_id) { 'minutely' } },
{ limit: 100, period: 1.hour, key_suffix: ->(job_id) { 'hourly' } },
{ limit: 1000, period: 1.day, key_suffix: ->(job_id) { 'daily' } }
]
) Will not appear on sidekiq UI, no throttling happens: sidekiq_throttle(
threshold: [
{ limit: 5, period: 5.minutes, key_suffix: 'minutely' },
{ limit: 100, period: 1.hour, key_suffix: 'hourly' },
{ limit: 1000, period: 1.day, key_suffix: 'daily' }
]
) This appears in the UI and correctly throttles sidekiq_throttle(threshold: { limit: 1, period: 1.second }) |
Follow up: I can confirm that this style works: sidekiq_throttle(
threshold: [
{ limit: 1, period: 1.second, key_suffix: ->(job_id) { 'secondly' } },
{ limit: 10, period: 1.minute, key_suffix: ->(job_id) { 'minutely' } }
]
) By "works" I mean that it correctly throttles the jobs at the 1/second and 10/minute rate. It was a red herring that the job is not listed in the /throttled page in Sidekiq Admin - only so-called "static" throttles appear there. If there is any |
Add docs about using string keys to create multiple limits per unit of time. I was confused about implementing this type of behavior until I saw your comment in #149, explaining the use of strings for the key_suffix. Hopefully this doc will help other realize they don't need a proc to do this but that the key_suffix is required for having multiple limits. I was simply doing this: ```ruby throttle: [ { limit: 500, period: 1.minute }, { limit: 18_000, period: 1.day } ] ``` This showed up in the UI on Sidekiq Admin as two separate throttles so it looked like it worked but it does not. Signed-off-by: Jake Moffatt <[email protected]>
Is it possible to set multiple throttle option like:
5 per 1 minute
100 per 1 hour
1000 per 1 day
All of them for the same worker.
The text was updated successfully, but these errors were encountered: