Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple worker/web processes on a single heroku app

Is there some way to configure multiple worker and/or web processes to run in the single Heroku app container? Or does this have to be broken up into multiple Heroku apps?

For example:

worker: node capture.js
worker: node process.js
worker: node purge.js
web: node api.js
web: node web.js
like image 321
tobius Avatar asked Apr 10 '14 13:04

tobius


People also ask

What is number of process types Heroku?

There are three primary process types: Web dynos: receive HTTP traffic from routers and typically run web servers. Worker dynos: execute anything else, such as background jobs, queuing systems, and timed jobs. One-off dynos: are temporary and not part of an ongoing dyno formation.

How many dynos do I need Heroku?

By default, applications are limited to 100 total dynos across all process types. Additionally, a single process type that uses performance dynos can't be scaled to more than 10 dynos. Submit a request to raise this limit for your application.

How do I run multiple commands in Procfile?

You can run multiple command inside Procfile using sh -c command : worker: sh -c 'firstCommand && secondCommand && etc...' Notes : Procfile should be at the project root level.

What is Heroku ps1 web scale?

Running heroku ps:scale web=1 will scale your app to one running dyno, basically meaning you have one server running your app currently.


1 Answers

All processes must have unique names. Additionally, the names web and worker are insignificant and carry no special meaning. The only process that carries a significant name is the web process, as stated in the Heroku docs:

The web process type is special as it’s the only process type that will receive HTTP traffic from Heroku’s routers. Other process types can be named arbitrarily. -- (https://devcenter.heroku.com/articles/procfile)

So you want a Procfile like so:

capture: node capture.js process: node process.js purge: node purge.js api: node api.js web: node web.js 

You can then scale each process separately:

$ heroku ps:scale purge=4 
like image 145
Yuval Adam Avatar answered Sep 18 '22 23:09

Yuval Adam