Question

I have a Django app running in Heroku with GUnicorn, I have 1Xdyno and just found that you can set your WEB_CONCURRENCY.

What's the optimal WEB_CONCURRENCY?

Was it helpful?

Solution

Article Deploying Python Applications with Gunicorn tells about various parameters of Gunicorn and their effect on Heroku.

Below is the text copied from this article regarding WEB_CONCURRENCY

Gunicorn forks multiple system processes within each dyno to allow a Python app to support multiple concurrent requests without requiring them to be thread-safe. In Gunicorn terminology, these are referred to as worker processes (not to be confused with Heroku worker processes, which run in their own dynos).

Each forked system process consumes additional memory. This limits how many processes you can run in a single dyno. With a typical Django application memory footprint, you can expect to run 2–4 Gunicorn worker processes on a 1X dyno. Your application may allow for a variation of this, depending on your application’s specific memory requirements.

We recommend setting a configuration variable for this setting, so you can tweak it without editing code and redeploying your application.

$ heroku config:set WEB_CONCURRENCY=3
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top