V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
miniyao
V2EX  ›  Python

Gunicorn 跑多个 worker,每个 worker 算是进程?还是线程?

  •  
  •   miniyao · 2019-03-10 20:13:43 +08:00 · 7827 次点击
    这是一个创建于 2089 天前的主题,其中的信息可能已经有所发展或是发生改变。
    1、用 Gunicorn 带 flask,Gunicorn 开 4 个 worker,每个 worker 算是进程?还是线程?(看到也有的介绍说,gunicorn 其实是个进程池)
    2、Gunicorn 开多个 worker,可以利用到多核 CPU 吗?
    3 条回复    2019-03-13 18:47:56 +08:00
    virusdefender
        1
    virusdefender  
       2019-03-10 20:23:40 +08:00
    -w 参数是进程,-t 是线程

    可以的
    Ehco1996
        2
    Ehco1996  
       2019-03-11 09:22:28 +08:00
    有个 worker class 默认的是 sync 也就是多进程的
    当然也有 gthread 多线程
    gevent 协程这种
    strict
        3
    strict  
       2019-03-13 18:47:56 +08:00
    >-w WORKERS, --workers=WORKERS
    >The number of worker processes. This number should generally be between 2-4 workers per core in the server. >Check the FAQ for ideas on tuning this parameter.


    >-k WORKERCLASS, --worker-class=WORKERCLASS
    >The type of worker process to run. You ’ ll definitely want to read the production page for the implications of this >parameter. You can set this to $(NAME) where $(NAME) is one of sync, eventlet, gevent, tornado, gthread, gaiohttp
    >(deprecated). sync is the default. See the worker_class documentation for more information.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1074 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 22:41 · PVG 06:41 · LAX 14:41 · JFK 17:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.