Search code examples
ruby-on-railsherokuconfigunicornproc

What do I set ENV["WEB_CONCURRENCY"] to when using heroku and sidekiq


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.


Solution

  • 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.