【问题标题】:Gunicorn with gevent workers and threadsGunicorn 与 gevent 工作人员和线程
【发布时间】:2016-04-22 09:27:32
【问题描述】:

我有一个 4 核的服务器。

在使用工作程序和线程设置 Gunicorn 时,我可以为 CPU 分配相同数量的工作程序和线程,因为它们会做不同的事情吗?

例如

from gevent import monkey
monkey.patch_all()
import multiprocessing

workers = multiprocessing.cpu_count() * 2 + 1
bind = "127.0.0.1:5000"
worker_class = 'gevent'
worker_connections = 1000
threads = multiprocessing.cpu_count() * 2 + 1

或者我应该这样做

from gevent import monkey
monkey.patch_all()
import multiprocessing

workers = 2 * 2 + 1
bind = "127.0.0.1:5000"
worker_class = 'gevent'
worker_connections = 1000
threads = 2 * 2 + 1

【问题讨论】:

    标签: python multithreading gunicorn gevent


    【解决方案1】:

    与 worker_class='gevent' 设置线程无关。请参阅文档中的引用,

    从 Gunicorn 19 开始,可以使用线程选项来处理请求 多个线程。使用线程假定使用 gthread 工作线程。 Gunicorn Design

    也来自线程设置文档,

    此设置仅影响 Gthread 工作线程类型。 Gunicorn Settings

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-20
      • 2012-04-14
      • 2015-01-20
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      相关资源
      最近更新 更多