Go to the Resources tab and in the Add-ons section type Heroku Redis in the search field. It will appear in the search list. Click on it and a modal will show up to install it, click in the Provision button to start the installation.
Check for the add-on availability using:
$ heroku addons | grep heroku-redis
After that, install it:
$ heroku addons:create heroku-redis:hobby-dev -a <app_name>
After installed, the Redis add-on will, automaticaly, create an environment varible call REDIS_URL
with the path to the Redis server.
To check the add-on status:
$ heroku addons:info redis-acute-19443
Where redis-acute-19443
is the name of the add-on. To check the add-on name, go to the Overview tab and in the Installed Add-ons section the name will appears in the Redis add-on.
Now that Redis is installed on Heroku. We need to setup Sidekiq in our Rails app to ensure that it will work on Heroku after the deploy.
In the project root create a Procfile
, this file will be used by Heroku to execute the commands added it.
Add this command:
worker: bundle exec sidekiq -c 2
worker
could be any name and -c 2
is the number thread running concurrently, in this case 2.
Push the changes to the repo and Heroku.
In the Free Dynos section under the Resource tab, will appear the worker
we add in the Procfile
, enable it clicking the edit button to right.
With this we have Sidekiq configured to use it on Heroku.
Check the Sidekiq logs in Heroku:
heroku logs --tail --app app_name --dyno worker
good!