django gunicorn 各worker class简单性能测试

版权归作者所有,任何形式转载请联系作者。
作者:petanne(来自豆瓣)
来源:https://www.douban.com/note/564871723/

======================================================================
测试环境:
======================================================================
双核虚拟机centos6.8,内存4G
python==2.7.11
gunicorn==19.6.0
django==1.9.2
tornado==4.3

======================================================================
gunicorn文档中支持的worker class:
======================================================================
sync 默认,使用同步阻塞的网络模型
eventlet - Requires eventlet >= 0.9.7
gevent - Requires gevent >= 0.13
tornado - Requires tornado >= 0.2
gthread - Python 2 requires the futures package to be installed
gaiohttp - Requires Python 3.4 and aiohttp >= 0.21.5

======================================================================
工具:
======================================================================
apache ab
如: ab -c 10 -n 100 -p post.txt http://www.test.com

======================================================================
测试参数:
======================================================================
gunicorn 进程数 -w 16 (与-w 8差距不大,测试机双核)
tornado 进程数16
post 1KB & HTTPResponse('hello world')
-c在保证Failed requests基本为0的前提下取最大值
使用-n为-c的10倍

======================================================================
guincorn运行django项目:
======================================================================
sync
-c 100 -n 1000 Requests per second 120
调整并发量结果仍然在120左右
CPU峰值80

eventlet
-c 50 -n 1000 Requests per second 230
Failed requests在180,即使-c 10,仍然有Failed requests
CPU峰值82

gevent
-c 500 -n 5000 Requests per second 230
Failed requests10以内,稳定
CPU峰值83

tornado
-c 200 -n 4000 Requests per second 250-350
Failed requests10左右,不稳定
但-c加到500,并发降为110,错误数100以内
CPU峰值85

可以看到gevent方式最稳定(推荐),eventlet错误数较多,tornado较高但不稳定

======================================================================
单独tornado项目,以多进程方式启动服务,不使用guincorn
======================================================================
-c 1000 -n 10000 Requests per second 1300-1500
CPU峰值80

======================================================================
以上均为真实测试数据,但由于测试环境及数据等原因,仅供参考
======================================================================

posted on   ExplorerMan  阅读(1063)  评论(0编辑  收藏  举报

编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
历史上的今天:
2018-02-19 python中set和frozenset方法和区别

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示