Skip to content

Getting Started

mperham edited this page Apr 25, 2012 · 77 revisions

Sidekiq makes every effort to make usage with Rails 3 applications as simple as possible. sidekiq does not support Rails 2.x.

Rails 3.x

  1. Add sidekiq to your Gemfile:
gem 'sidekiq'
  1. Add a worker in app/workers to process messages asynchronously:
class HardWorker
  include Sidekiq::Worker
  def perform(name, count)
    # do something
  end
end
  1. Send a message to be processed asynchronously:
HardWorker.perform_async('bob', 5)
  1. Start sidekiq from the root of your Rails application so the message will be processed:
sidekiq

That's it. You do not need to turn on thread-safe mode. You probably should tune your ActiveRecord pool size if your workers are using ActiveRecord. See Advanced Options for more detail.

non-Rails

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

Clone this wiki locally