Python 获取服务器的CPU个数

在使用gunicorn时,需要设置workers,

例如:

gunicorn --workers=3 app:app -b 0.0.0.0:9000

其中,worker的数量并不是越多越好,推荐值是CPU的个数x2+1,

CPU个数使用如下的方式获取:

python -c 'import multiprocessing; print multiprocessing.cpu_count()'

//输出:1  ,即1核

虚拟机只有1个CPU,可以启动3个worker(1*2+1)

posted @ 2019-07-16 15:49  大西瓜Paul  阅读(4253)  评论(0编辑  收藏  举报
/*增加返回顶部按钮*/ 返回顶部 /*给标题增加蓝色背景长条*/