How do you run multiple DelayedJob workers on a single Heroku dyno? How do you run multiple DelayedJob workers on a single Heroku dyno? heroku heroku

How do you run multiple DelayedJob workers on a single Heroku dyno?


You can use foreman to start multiple processes on the same dyno.

First, add foreman to your Gemfile.

Then add a worker line to your Procfile:

worker: bundle exec foreman start -f Procfile.workers

Create a new file called Procfile.workers which contains:

dj_worker: bundle exec rake jobs:workdj_worker: bundle exec rake jobs:workdj_worker: bundle exec rake jobs:work

That will start 3 delayed_job workers on your worker dyno.


Try changing your Procfile to:

worker: bundle exec script/delayed_job -n 3 run

Using start will create two daemons in the background and then immediately exit. Heroku thinks that your process crashed.

Using run keeps the workers in the foreground.

UPDATE: I use Delayed Job Worker Pool for this now.


Short answer is that you can't do this with delayed_job. A dyno is a process and a single delayed_job worker works on a single process.

There are other solutions to this though. If you can switch over to using Sidekiq then you can run quite a few workers on a single process since Sidekiq workers use threading. The trade-off here is that your workers will need to be thread safe.

Check it out: http://sidekiq.org/