Pregunta

As I'm trying to deploy my app to Heroku, I have set up the procfile and unicorn.rb file in accordance with heroku's guide. However, at the top of the file there is a line

worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)

I suppose that this wants me to set WEB_CONCURRENCY= inside of the .env file. However, I am not really sure what I should set that equal to.

¿Fue útil?

Solución

Basically, it is how many worker processes you want within each dyno. See here. Each worker process will allow you to run a concurrent request on the same dyno. Each worker process consumes some memory, so more worker processes will make your app run slower. It looks like Heroku recommends 2-4 worker processes, so I would set it somewhere in there. If you don't set anything, it will default to 3, which is probably a good number.

Bottom line: You need to set it to an integer, likely between 2 and 4. Unless you have reason to change it, it's probably fine to leave it with the default of 3.

Otros consejos

To enable WEB_CONCURRENCY to be set to a default value based on dyno size

$ heroku config:set SENSIBLE_DEFAULTS=enabled
$ git commit --allow-empty -m "enable sensible defaults"
$ git push heroku master
$ heroku run bash --size 2X
Running `bash` attached to terminal... up, run.7530
~ $ echo $WEB_CONCURRENCY
4

When enabled the value will default to:

  • 1X dynos: WEB_CONCURRENCY=2
  • 2X dynos: WEB_CONCURRENCY=4
  • PX dynos: WEB_CONCURRENCY=16

This will change your WEB_CONCURRENCY based on your dyno type and size read more here

If you are using 2+ 2X Standard Dynos or PX Performance Dynos you can increase them and set to some other value depending upon avg memory footprint of unix processes forked by unicorn. Else standard practice says keep the number between 2-4 or default to 3

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top