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
======================================================================
以上均為真實測試數據,但由于測試環境及數據等原因,僅供參考
======================================================================
轉載于:https://www.cnblogs.com/ExMan/p/10403827.html
總結
以上是生活随笔為你收集整理的django gunicorn 各worker class简单性能测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python json模块
- 下一篇: 公司电脑用域账号访问团队文件夹