我正在使用 Heroku 来托管一个 django 应用程序,并且我正在使用 Waitress 作为我的 Web 服务器。我运行 2 (x2) dynos,我在 New Relic 实例选项卡中看到我有 10 个实例正在运行。
我想知道 Heroku 在使用 Waitress 时如何确定在一个 Dyno 上运行的 Web 服务器进程的数量?
我知道在使用 Gunicorn 时,有一种方法可以设置每个 dyno 的进程数,但没有看到在 Waitress 中定义它的任何方法。
谢谢!
In Waitress, there is a master process and (by default) 4 worker threads or processes. You can change this if you wish. Here is the docs for these options for waitress-serve
http://waitress.readthedocs.org/en/latest/runner.html#runner
--threads=INT
Number of threads used to process application logic, default is 4.
So if you have 2 dynos, and 5 (4+1) threads on each, then the total would come to 10 instances for this app in the RPM dashboard.
One can add more processes to the dynos as the maximum supported on Heroku 2x dynos is much higher:
2X dynos support no more than 512
https://devcenter.heroku.com/articles/dynos#process-thread-limits
But, you may want to check out some discussion on tuning this vs Gunicorn
:
Waitress differs, in that it has an async master process that buffers the entire client body before passing it onto a sync worker. Thus, the server is resilient to slow clients, but is also guaranteed to process a maximum of (default) 4 requests at once. This saves the database from overload, and makes scaling services much more predictable.
Because waitress has no external dependencies, it also keeps the heroku slug size smaller.
https://discussion.heroku.com/t/waitress-vs-gunicorn-for-docs/33
因此,在与新遗物支持人员交谈后,他们澄清了这个问题。显然,实例选项卡中只计算进程(线程不计算在内)。
在我的 Procfile 中,我还在监视将实例添加到实例选项卡的 RabbitMQ 工作人员,因此不匹配。引用他们的答案:
我与我们的开发人员澄清了我们如何准确地测量“实例”选项卡的实例。Python 代理将每个受监控的进程视为一个实例。线程不算作附加实例。我注意到您不仅在监控您的 django/waitress 应用程序,而且还在监控一些后台任务。看起来后台任务加上 django 进程加起来总共有 10 个被监控的进程。