Decrementable Option

The Decrementable option, when enabled (recommended), allows the Worker Dyno Manager to scale down gradually. This means that it will be able to scale down, for example, from 5 to 3, 3 to 2, etc. When this option is disabled, the Dyno Manager will not scale down at all until the queue is empty. This means that instead of scaling down gradually, it will, for example, maintain 5 worker dynos until the queue is entirely empty, and then it will scale directly from 5 to 0 worker dynos.

Generally speaking, you will want to keep this option enabled. As the Dyno Manager cannot control which specific worker to scale down, it will result in Heroku scaling down worker dynos that are still actively processing jobs.

This isn't necessarily an issue, but you need to take this into account. Heroku provides a 30-second grace period between when the Dyno Manager instructs Heroku to scale down and the one or more worker dynos from shutting down, giving these workers the opportunity to perform a clean shutdown. Heroku first issues a SIGTERM signal to the worker dynos that it wants to shut down. Many worker libraries intercept this signal and stop consuming jobs from the queue and attempt to finish the jobs that they are currently processing. Once they finish processing those jobs, the process will cleanly exit.

If all of your jobs take less than 30 seconds to process, then dynamically shutting down worker dynos, even those that are still processing jobs, shouldn't be an issue as they would have the ability to finish their worker prior to shutting down.

If certain jobs take longer than 30 seconds to complete, then this may be an issue. In this case, you can structure those jobs so that they are idempotent or run in stages as a chain of jobs, where one job enqueues the next job once it's done. Each stage should take less than 30 seconds to complete. This way, you can scale up and down as much as you want without interrupting a single job.


See: https://devcenter.heroku.com/articles/queuing-ruby-resque#job-termination

Still need help? Contact Us Contact Us