How do Heroku workers work ?

Active3 hr before
Viewed126 times

3 Answers


A client sends an app a request to perform a task that is well suited to a background job.,When the worker process completes the task, it persists the outcome of the task. For example, in the case of uploading a file to Amazon S3, it might persist the file’s S3 URL.,The following are the high-level steps for handling a request that uses a background job:,A separate app process (known on Heroku as a worker process) notices that a task was added to the job queue. It takes the task off of the queue and begins performing it.

web: lein run - m myapp.web
worker: lein run - m myapp.worker
load more v

Background: I'm trying to understand how they work for my own sake, but also to help me decide whether I should use a worker or a clock for a homemade mailing/newsletter system I'm adapting to Heroku.,They will run once deployed and keep running unless an exit command is issued or if the script returns an error. On my experience, when an error occurs, it's interrupted immediately and restarted after some time (which seems random). I'm not sure if it will restart when a clean exit is executed.,Heroku supports multiple types of dyno configurations and allows us to set both a web and a worker process type for an app, for example like so:, Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers

Heroku supports multiple types of dyno configurations and allows us to set both a web and a worker process type for an app, for example like so:

web: vendor / bin / heroku - php - apache2 web /
   worker: php worker / myworker.php
load more v

In simple terms, a dyno is an isolated, virtualized UNIX container that provides the environment required to run an application., Dynos, where your application code actually runs day to day ,So a dyno is a container that holds our code and our configuration, but how do we get our application code into them? Heroku calls this process slug compilation.,Before we talk about the process of creating a release that is deployed onto Heroku, let’s quickly define what a release is.

A better solution is to use environment variables, and keep the keys out of the code. On a traditional host or working locally, you can set environment vars in your bashrc. On Heroku, you use config vars:

$ heroku config: set GITHUB_USERNAME = joesmith
Adding config vars and restarting myapp...done, v12

$ heroku config
OTHER_VAR: production

$ heroku config: get GITHUB_USERNAME

$ heroku config: unset GITHUB_USERNAME
Unsetting GITHUB_USERNAME and restarting myapp...done, v13
load more v