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

2019-03-10 20:13:43 +08:00
 miniyao
1、用 Gunicorn 带 flask,Gunicorn 开 4 个 worker,每个 worker 算是进程?还是线程?(看到也有的介绍说,gunicorn 其实是个进程池)
2、Gunicorn 开多个 worker,可以利用到多核 CPU 吗?
7819 次点击
所在节点    Python
3 条回复
virusdefender
2019-03-10 20:23:40 +08:00
-w 参数是进程,-t 是线程

可以的
Ehco1996
2019-03-11 09:22:28 +08:00
有个 worker class 默认的是 sync 也就是多进程的
当然也有 gthread 多线程
gevent 协程这种
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.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/543086

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX