django gunicorn 各worker class简单性能测试
版權(quán)歸作者所有,任何形式轉(zhuǎn)載請(qǐng)聯(lián)系作者。
作者:petanne(來自豆瓣)
來源:https://www.douban.com/note/564871723/
======================================================================
測(cè)試環(huán)境:
======================================================================
雙核虛擬機(jī)centos6.8,內(nèi)存4G
python==2.7.11
gunicorn==19.6.0
django==1.9.2
tornado==4.3
======================================================================
gunicorn文檔中支持的worker class:
======================================================================
sync 默認(rèn),使用同步阻塞的網(wǎng)絡(luò)模型
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
======================================================================
測(cè)試參數(shù):
======================================================================
gunicorn 進(jìn)程數(shù) -w 16 (與-w 8差距不大,測(cè)試機(jī)雙核)
tornado 進(jìn)程數(shù)16
post 1KB & HTTPResponse('hello world')
-c在保證Failed requests基本為0的前提下取最大值
使用-n為-c的10倍
======================================================================
guincorn運(yùn)行django項(xiàng)目:
======================================================================
sync
-c 100 -n 1000 Requests per second 120
調(diào)整并發(fā)量結(jié)果仍然在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以內(nèi),穩(wěn)定
CPU峰值83
tornado
-c 200 -n 4000 Requests per second 250-350
Failed requests10左右,不穩(wěn)定
但-c加到500,并發(fā)降為110,錯(cuò)誤數(shù)100以內(nèi)
CPU峰值85
可以看到gevent方式最穩(wěn)定(推薦),eventlet錯(cuò)誤數(shù)較多,tornado較高但不穩(wěn)定
======================================================================
單獨(dú)tornado項(xiàng)目,以多進(jìn)程方式啟動(dòng)服務(wù),不使用guincorn
======================================================================
-c 1000 -n 10000 Requests per second 1300-1500
CPU峰值80
======================================================================
以上均為真實(shí)測(cè)試數(shù)據(jù),但由于測(cè)試環(huán)境及數(shù)據(jù)等原因,僅供參考
======================================================================
轉(zhuǎn)載于:https://www.cnblogs.com/ExMan/p/10403827.html
總結(jié)
以上是生活随笔為你收集整理的django gunicorn 各worker class简单性能测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python json模块
- 下一篇: 公司电脑用域账号访问团队文件夹