Getting Started

Michael Pope edited this page May 22, 2018 · 48 revisions

Sidekiq makes every effort to make usage with modern Rails applications as simple as possible. Please see the ActiveJob page if you want to use Sidekiq with ActiveJob.


  1. Add sidekiq to your Gemfile:
gem 'sidekiq'
  1. Add a worker in app/workers to process jobs asynchronously:
rails g sidekiq:worker Hard # will create app/workers/hard_worker.rb
class HardWorker
  include Sidekiq::Worker
  def perform(name, count)
    # do something
  1. Create a job to be processed asynchronously:
HardWorker.perform_async('bob', 5)

Note that perform is an instance method, whereas perform_async is called on the class.

You can also create a job to be processed in the future:

HardWorker.perform_in(5.minutes, 'bob', 5)

NOTE: If you are testing this out in Rails console and you use spring you may need to stop spring so that you can access the new worker.

  1. Start sidekiq from the root of your Rails application so the jobs will be processed:
bundle exec sidekiq

That's it. You probably should tune your Active Record pool size if your workers are using Active Record. See Advanced Options for more detail.

Plain Ruby

There are some non-Rails examples in examples/. por.rb is a "Plain Old Ruby" example, and sinkiq.rb is a Sinatra integration.

Watch an overview:

Getting Started

Next: The Basics

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.