Skip to content
Autoscaling Delayed Job workers on Heroku to save money
Ruby
Pull request Compare This branch is 1 commit ahead of phaza:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
heroku_delayed_job_autoscale.gemspec

README.md

Heroku Delayed Job Autoscale

Simply put, this gem saves you money on Heroku by only running the workers when you need them.
When a new job is enqueued, this gem will fire up a new worker instance if none are running. When the job finishes, it'll shut it down.

Usage

Create a delayed job worker and include HerokuDelayedJobAutoscale::Autoscale:

class OnImageUpload
  include HerokuDelayedJobAutoscale::Autoscale

  def initialize(media)
    @media = media
  end

  def perform
    @media.create_thumb
  end
end

Done

Requirements

I haven't tested lower versions, but it might work.

Caution

Autoscale uses two DJ hooks. #after and #enqueue, which it just passes onto two methods autoscale_after and autoscale_enqueue. If you need to use either of those hooks yourself in your DJ worker, make sure you pass on the job to the autoscale_methods manually.

Other

Work is based of pedro's autoscaling branch, but adapted for Delayed Job 2.1 and rails 3.

Something went wrong with that request. Please try again.