Skip to content
gunicorn最佳配置
2025年3月13日 root

workers 数目

每个work是一个进程, 建议数量设置为: (2*CPU)+1.

shell
gunicorn --workers=5 main:app

threads 数目

threads 数目默认是1, python的GIL原因多线程提升不大 i/o密集型指定threads有一定的作用 cpu密集型指定threads没啥作用

shell
gunicorn --workers=5 --threads=2 main:app

在当前的设置中, 可以处理的并发量是5*2=10个

单cpu设置

shell
gunicorn --worker-class=gevent --worker-connections=1000 --workers=3 main:app

在当前的设置中, 可以处理的并发量是1000*3=3000个

Last updated: