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

Throttling queues #7

Closed
bloudermilk opened this issue Jul 19, 2013 · 4 comments
Closed

Throttling queues #7

bloudermilk opened this issue Jul 19, 2013 · 4 comments

Comments

@bloudermilk
Copy link

It would be great if users could throttle an entire queue, regardless of which worker was running on it. In my case, I have ~15 job types that all need to respect the same rate limit.

@gevans
Copy link
Owner

gevans commented Jul 19, 2013

You should be able to do this by using the same :key option when specifying sidekiq_options for each worker:

sidekiq_options queue: :critical, throttle: { key: :critical, threshold: 20, period: 1.hour }

Is this the solution you're looking for?

@bloudermilk
Copy link
Author

@gevans ah, didn't realize the key was shared across workers. So this would look something like the following?

class FooWorker
  include Sidekiq::Worker
  sidekiq_options queue: :critical, throttle: { key: :critical, threshold: 20, period: 1.hour }
end

class BarWorker
  include Sidekiq::Worker
  sidekiq_options queue: :critical, throttle: { key: :critical, threshold: 20, period: 1.hour }
end

@gevans
Copy link
Owner

gevans commented Jul 19, 2013

Exactly. :) The readme needs to be organized a bit better. The :key option by default translates the class name and queue into a string. It's responsible for naming the rate limit when checking the thresholds.

So FooWorker and BarWorker would have their :keys set to foo_worker:critical and bar_worker:critical.

@bloudermilk
Copy link
Author

@gevans appreciate the prompt response. Will let you know if I have any more issues.

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

No branches or pull requests

2 participants