Rails: Starting Sidekiq on Heroku

It's worth checking if the sidekiq process is really started with this command:

heroku ps

If there's no worker, then you might need to run this command:

heroku ps:scale worker+1

It turns out that there's a bug in the web UI in that some team members were not allowed to increase the number of workers from 0 to 1, even though the UI seemed to show that!


Complementing gdurelle answer:

You do need some config with Heroku for Sidekiq:

1) Have the Sidekiq and Redis gems installed (in gemfile and bundled), in my case:

Gemfile

gem 'redis', '~> 3.1'
gem 'sidekiq', '~> 2.7', '>= 2.7.1'

2) Add a worker, if you don't have any workers created locally I suggest you create at least one, just in case, use this:

rails g sidekiq:worker Hard # will create app/workers/hard_worker.rb

should create this:

app/workers/hard_worker.rb

class HardWorker
  include Sidekiq::Worker
  def perform(name, count)
    # do something
  end
end

3) Add the Redis add-on (in my case Heroku Redis):

heroku addons:create heroku-redis:hobby-dev

4) Add your redis.rb file, in my case:

config/initializers/redis.rb

$redis = Redis.new(url: ENV["REDIS_URL"])

5) Add Procfile or config/sidekiq.yml or both, here are mine:

Procfile

worker: bundle exec sidekiq -c 1 -q default -q mailers 

which you can create easier by pasting this in your terminal

echo "worker: bundle exec sidekiq -c 1 -q default -q mailers" > Procfile

config/sidekiq.yml

:concurrency: 1
:queues:
  - [mailers, 7]
  - [default, 5]

6) Most important part go here: and turn on the switch for your worker, click on the pencil and then turn on the missing switch. Things should be working fine now, have a great day!


No you do not need any config with Heroku for Sidekiq, just add the RedisToGo plugin and you're on. Do not forget to attribute at least 1 worker to your app in your Heroku config.

Here is my default Procfile:

web: bundle exec thin start -p $PORT
worker: bundle exec sidekiq -c 5 -v

Starting with sidekiq version 3.0 there is an additional step, run heroku config:set REDIS_PROVIDER=REDISTOGO_URL in the console.

Here is the process I used for Rails 4:

In the console:

heroku addons:create redistogo
heroku config:set REDIS_PROVIDER=REDISTOGO_URL

In my Procfile I added:

worker: bundle exec sidekiq

In my gemfile.rb I added:

gem 'redis'

I added the following file, config/initializers/redis.rb:

uri = ENV["REDISTOGO_URL"] || "redis://localhost:6379/"
REDIS = Redis.new(:url => uri)

Here is the link to the sidekiq docs.