Throttling queues
bloudermilk opened this issue · comments
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.
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?
@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
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 :key
s set to foo_worker:critical
and bar_worker:critical
.
@gevans appreciate the prompt response. Will let you know if I have any more issues.