From Sidekiq to Shoryuken

Pablo Cantero edited this page Jul 2, 2017 · 28 revisions

Shoryuken is a drop-in replacement for Sidekiq, the code changes should be minor s/sidekiq/shoryuken. But as Shoryuken "reads" messages from SQS, instead of Redis, you will probably need a three steps migration:

  • Stop sending jobs to Sidekiq
  • Start using Shoryuken
  • Keep Sidekiq running until it consumes all pending jobs.

Worker

Sidekiq

class MyWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'my_queue'

  def perform(arg)
    # ...
  end
end

Shoryuken

class MyWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'my_queue', auto_delete: true

  def perform(sqs_msg, arg)
    # ...
  end
end

Configuration file

sidekiq.yml

concurrency: 25
pidfile: tmp/pids/sidekiq.pid
queues:
  - default
  - [myqueue, 2]

shoryuken.yml

concurrency: 25
pidfile: tmp/pids/shoryuken.pid
queues:
  - default
  - [myqueue, 2]

Sending messages

Sidekiq

MyWorker.perform_async('test')

Shoryuken

MyWorker.perform_async('test')

To get it running

Sidekiq

bundle exec sidekiq -r ./my_worker.rb -q my_queue

Shoryuken

bundle exec shoryuken -r ./my_worker.rb -q my_queue
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.