我有一个Django
个应用在Heroku
中与GUnicorn
一起运行,我有1Xdyno
,并且发现您可以设置WEB_CONCURRENCY
。
什么是最佳WEB_CONCURRENCY
?
答案 0 :(得分:2)
文章Deploying Python Applications with Gunicorn讲述了Gunicorn的各种参数及其对Heroku的影响。
以下是本文中与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