Save $414 on Your Heroku Bill This Year
Run Delayed Job in threads to eliminate dedicated dynos for background jobs on Heroku.
Many of the Rails projects I’ve worked on consist of sophisticated web front-ends with a simple asynchronous background processing to send emails, improve interface responsiveness, run scheduled tasks, and maintain up-to-date data sources. I’ve had great success with Delayed Job in particular.
On Heroku, the traditional guidance is that Delayed Job should run on a dedicated ‘worker’ dyno for $34.50 a month. Since the first web dyno is free, wouldn’t it be great to be able to avoid worker dynos altogether for smaller apps and run background jobs in a thread on the web dynos? The general approach should work for any stack, here’s how to do it for Delayed Job + Active Record in your Rails app.
- Upgrade to the threaded Puma Webserver
- Add this snippet of code to your delayed_job.rb initializer
- Restart your app.
Did this post save you $414 dollars or more this year? Tips welcome: