Configure Requeue Strategies
mainWhen a job is throttled, it must be requeued. You can choose between two strategies:
:enqueue(Default): Puts jobs immediately back on the queue. This can cause high Redis CPU usage if many jobs are constantly being dequeued and re-enqueued.:schedule: Schedules the work for the future. This reduces Redis load by delaying the check until the job is likely to be runnable.
Global Configuration
You can set a default strategy globally:
Sidekiq::Throttled.configure do |config|
config.default_requeue_options = { with: :schedule }
endPer-job Configuration
You can specify the strategy and even a target queue for a specific job:
# Using :schedule strategy
sidekiq_throttle(
threshold: { limit: 5, period: 1.minute, requeue: { with: :schedule } }
)
# Using :schedule strategy and moving to a different queue
sidekiq_throttle(
threshold: { limit: 5, period: 1.minute, requeue: { to: :other_queue, with: :schedule } }
)sidekiq_throttle(
threshold: { limit: 5, period: 1.minute, requeue: { with: :schedule } }
)