Sidekiq is a free, open-source background job processor for Ruby. It runs tasks such as sending emails, charging credit cards, generating reports, and calling external APIs outside the request-response cycle, so users don’t have to wait. Sidekiq stores job queues in Redis and processes jobs in multiple threads, which makes it faster and lighter on memory than Resque and Delayed_job.
Mike Perham introduced Sidekiq in 2012, and after 10 years it is probably still the most common background job system for Ruby. This Sidekiq tutorial is for developers starting out with Ruby on Rails and those picky about their stack. If you are still choosing a framework, our Django vs Ruby on Rails comparison can help. Our guide on how apps are made shows the bigger picture.
Below, we cover what Sidekiq is, how it got so popular, who uses it, how it compares to Resque and Delayed_job, and how to use it in plain Ruby and Ruby on Rails: scheduling workers, sending emails, and testing jobs.
What is Sidekiq?

Bruce Lee against Chuck Norris via Giphy
Sidekiq is a free and open-source Ruby job scheduler that was created by Mike Perham. Ruby programming language is one of our most used and well-mastered tools we respect and love. If you’re interested in why we recommend it for clients’ projects, check out our separate article on Ruby. If you don’t have that spare 10 minutes of your life to get to know our inner development processes (we totally understand), then let’s round it up in 4 sentences and introduce you to the major topic of this article:
1. Ruby is a programming language.
2. When developing a Ruby on Rails application, you might find yourself overwhelmed with myriads of tasks that must be executed at the same time.
3. For example, sending emails, charging credit cards, interacting with external APIs, and other data processing.
4. Developers use tools like Sidekiq that allow them to run background jobs, i.e., automated processes outside of the request-response cycle so users don’t have to wait in a queue.
So, Sidekiq is a default tool for a Ruby application that improves its performance and response wait time.
Enterprise version
While Sidekiq is free by default, it doesn’t schedule jobs and only executes them. The paid version of the tool — Enterprise version — comes with scheduling. Mark Perham, its creator, didn’t aim to divide the tool into paid and free versions. Rather, this idea came to him accidentally.
Redis
Sidekiq works closely with Redis 4.0+ to organize job queues an d store statistics. Redis (stands for Remote Dictionary Server) is a fast open source in-memory key-value data store. It provides sub-millisecond response times and allows real-time applications to run millions of requests per second.
Workers and queues
The scheduler is run as the copy of the application in a separate process and can be configured to use several worker threads. Each worker is assigned to one or many queues. Queues represent the list of tasks in the order they are added and can be named by purpose (default, mail, reports) or by priority (low, normal, high) — it’s completely up to the developer.
Sidekick 6.3, the latest version of the tool, came out in November 2021. Introducing the new version, Mark Perham elaborates on how to use the term “worker” correctly. What exactly is a worker?
“Are you talking about a process? A thread? A type of job? I encourage developers to stop using the term worker and use include Sidekiq::Job in your job classes” — M.P.
class SomeJob
include Sidekiq::Job
sidekiq_options ...
def perform(*args)
end
end
Plugins
Sidekiq has a myriad of prominent features: retries with configurable periods, flexible error handling, a web UI and a ton of plugins extending its functionality further.
One of such plugins, for example, introduces repeated tasks on schedules, which were historically solved by tools based on cron. Cron is harder to configure and takes time to start the whole app for execution of a single task.
Another plugin monitors various metrics and checks for Sidekiq to avoid errors. You can find many more on GitHub!
How did Sidekiq get so popular?

Single, married, multi-threading? Image by @dwfries on Medium
In 2012, Mike Perham was the first to introduce a multi-threading background job system. Resque is multi-process and single-thread. Delayed_job can work for single thread processing only. Sidekiq was the first multi-threading tool in the Ruby community. With time, it became the main driver of avoiding thread safety bugs in the Rails ecosystem. Because Sidekiq is omnipresent, it has stabilized the thread safety of Rails.
Who uses Sidekiq?
Sidekiq has become the de facto standard for web applications these days. According to Stackshare, Sidekiq is used by such well-known companies as:
- Adidas,
- GitLab,
- Product Hunt,
- Send Grid,
- New Relic,
- 500px,
- and many more.
A pick into companies using Sidekiq via Stackshare
How does Sidekiq compare to other similar tools?
There are alternative projects with more or less the same set of features. In this article, we compare Sidekiq to its most popular competitors: Resque and Delayed_job.
Resque
Resque is a Ruby library for creating background jobs. You can place them on multiple queues and process them later. Background jobs can be any Ruby class or module. Existing classes can be converted to background jobs. Resque also offers an option to create new classes.
Resque has a slightly different concurrency model from Sidekiq, which may or may not be what you are looking for. While Sidekiq uses threads for its workers (and can’t scale onto many CPU cores), Resque uses processes, which makes it slightly more heavy-weight on one side, but lets it use cores of CPUs. This is important for computationally heavy tasks when the single-CPU threading model doesn’t apply well.

Sidekiq vs Resque statistic on stackshare
Unlike Sidekiq, Resque doesn’t require thread safety and works with any gem (Ruby programs and libraries). According to developers though, Sidekiq runs faster and uses much less memory.
Delayed_job
Delayed_job, a.k.a. DJ is a priority queue, database-oriented tool that allows to execute background tasks asynchronously. It was originally extracted from Shopify and has become very popular through the years.
According to Doug Breaker, who researched DJ in comparison to Sidekiq, there are several features the latter doesn’t have:
- Easy integration with Rails that doesn’t depend on a relational database/non-relational database.
- Custom data store. You can use the main data store to process tasks offline and customize a data store to fit your needs.
- No need to run multiple dependencies at once, e.g., instead of requiring multiple services and dependencies to run a program, you can limit the dependencies that you need.
Delayed::job, sadly, doesn’t support multi-threading, unlike Sidekiq. The latter also runs faster, is scalable, and has the ability to run Redis automatically.

Sidekiq vs Delayed_job statistic on stackshare
Using Sidekiq in plain Ruby
Now that you know of the alternatives, let’s learn how to use Sidekiq in practice.
Sidekiq is framework-agnostic and can be used in any Ruby application. The official Getting Started guide provides detailed steps on how to get up and running.
The gist is that you:
1. Add Sidekiq to your Gemfile:
# Gemfile
gem 'sidekiq'
2. Define worker classes:
# app/workers/generate_report_worker.rb
class GenerateReportWorker
include Sidekiq::Worker
def perform(user_id)
# do your reporting here
end
end
3. Start Sidekiq as a separate process:
$ bundle exec sidekiq
4. Start scheduling your workers:
# Task is to be executed as soon as possible
GenerateReportWorker.perform_async(user.id)
# Task is to be executed in 5 minutes
GenerateReportWorker.perform_in(5 * 60, user.id)
# Task is to be executed at a certain moment (3 hours from now)
GenerateReportWorker.perform_at(Time.now + 10800, user.id
5. To execute a worker immediately:
MySimpleWorker.new.perform("I was performed!")
Using Sidekiq in Ruby on Rails
There is not much difference between using Sidekiq in plain old Ruby or in Ruby on Rails programming. Rails remains one of the most used web frameworks, so this setup is very common. You still get a nice integration with Rails Active Job framework and you can use Date/Time helpers when scheduling future tasks:
Date/Time helpers examples
# Generate report next Monday
GenerateReportWorker.perform_at(Time.current.next_week, user.id)
E.g., generate a report in 5 minutes:
GenerateReportWorker.perform_in(5.minutes, user.id)
Active Job integration
Active Job is a standard interface for interacting with job runners. According to the official guide, it is a framework with a variety of queuing back-ends. The jobs could be:
- Regularly scheduled clean-ups,
- Billing charges,
- Emails,
- Anything you can imagine running in parallel.
If you want your workers to not be Sidekiq-specific, you need to take several steps:
1. Define your workers as ActiveJob jobs:
# app/jobs/generate_report_job.rb
class GenerateReportJob < ActiveJob::Base
# The name of the queue to put this job into
queue_as :default
def perform(user_id)
# do your reporting here
end
end
2. Configure Rails application to use the correct adapter:
# config/application.rb
class Application < Rails::Application
# ...
config.active_job.queue_adapter = :sidekiq
end
3. Use ActiveJob syntax for scheduling:
# Generate report as soon as possible
GenerateReportJob.perform_later(user.id)
There are plenty of configuration options.
Sending emails with ActionMailer and Sidekiq
ActionMailer allows you to send emails (surprise!) from your Ruby app. Here is what you need to send emails asynchronously with Sidekiq:
1. For creating a mailer:
# app/mailers/users_mailer.rb
class UsersMailer < ActionMailer::Base
def welcome_email(user_id)
@user = User.find(user_id)
mail(to: @user.email, subject: "Welcome") do |format|
format.text
format.html
end
end
end
2. See views on emails:
app/views/users_mailer/welcome_email.html.erb - HTML version
app/views/users_mailer/welcome_email.text.erb - TEXT version
3. Finally, sending emails:
user = User.find(1)
mail = UsersMailer.welcome_email(user.id)
# mail.deliver_now
mail.deliver_later
Testing Sidekiq jobs (with RSpec framework)
Sidekiq provides tools for testing the various aspects of your workers at any stage of their lifecycle. To test workers directly, use:
worker = MyWorker.new
worker.perform(:my_arg)
Or you can use an inline mode:
# implementation
class DeleteFromRemoteApiWorker
include Sidekiq::Worker
def perform(item_ids)
ApiWrapper.delete_items(item_ids) # dependency
end
end
# test
describe DeleteFromRemoteApiWorker do
let(:items) do
# ...
end
it "delegates the work to the API wrapper as expected" do
allow(ApiWrapper).to receive(:delete_items)
item_ids = items.map(&:id)
described_class.perform_async(item_ids)
expect(ApiWrapper).to(
have_received(:delete_items).with(item_ids)
)
end
end
FAQ
What is Sidekiq used for?
Sidekiq is used to run background jobs in Ruby and Ruby on Rails applications. Typical jobs are sending emails, charging credit cards, interacting with external APIs, generating reports, billing charges, regular clean-ups, and other data processing. Running them outside the request-response cycle improves the app’s performance and response time, because users don’t wait for these tasks to finish.
What is the difference between Sidekiq and Resque?
The main difference is the concurrency model. Sidekiq uses threads for its workers, while Resque uses processes. Processes make Resque heavier, but they let it use several CPU cores, which helps with computationally heavy tasks. Resque doesn’t require thread safety and works with any gem. Sidekiq, on the other hand, runs faster and uses much less memory.
How does Sidekiq compare to Delayed_job?
Delayed_job is a database-oriented priority queue originally extracted from Shopify. It integrates easily with Rails, lets you use your main data store, and needs fewer dependencies, since it doesn’t require Redis. However, Delayed_job doesn’t support multi-threading. Sidekiq runs faster, scales better, and processes jobs in multiple threads, which is why it became the default choice for many Ruby teams.
Does Sidekiq require Redis?
Yes. Sidekiq works with Redis 4.0+ to organize job queues and store statistics, and it uses exclusively Redis as its database. Redis is a fast, open-source, in-memory key-value store with sub-millisecond response times. This dependency might not suit every project, so teams that want to avoid running Redis sometimes choose a database-backed tool such as Delayed_job instead.
How do you use Sidekiq in Ruby on Rails?
Add the sidekiq gem to your Gemfile, define worker classes that include Sidekiq::Worker with a perform method, and start Sidekiq as a separate process with bundle exec sidekiq. Then schedule jobs with perform_async, perform_in, or perform_at. In Rails, you can also set config.active_job.queue_adapter = :sidekiq and write jobs with the standard Active Job syntax, such as perform_later.
Why do we (still) use Sidekiq in outsourced projects?
Mastering Sidekiq is not something you’ll need a triple digits IQ for. Nevertheless, stable and reliable software is a must for processing thousands of workers. This tool uses exclusively Redis as its database, which might not suit all. Memory leaks are also a thing to be aware of…
Nevertheless, Sidekiq architecture is perfect when working with complex Ruby applications. For example, we created a virtual learning environment complete with live chats, video streaming, billing charges, and more, with Sidekiq in our tech stack.
Sidekiq is ideal for those who require fast speed, executing 7100 jobs per second. Multi-threading abilities mean that multiple jobs can be queued in the background without affecting the synchronous workflow of the application, improving overall performance.
So, is Sidekiq still our best buddy? Yes! Happy birthday, Sidekiq! 🎂

Image via Giphy
Written by Aleksey Gureiev & Rita Kind-Envy
Related reading
