zoukankan      html  css  js  c++  java
  • 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

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

  • 相关阅读:
    WPF中的brushes
    com中的线程模式(转)
    线程同步
    WPF线程
    应用程序管理(Application)
    WPF的继承结构树
    HTML技巧100例(一)
    多个网站共用一个空间的超值玩法
    用JavaScript实现浏览器地震效果
    HTML技巧100例(二)
  • 原文地址:https://www.cnblogs.com/ExMan/p/10403827.html
Copyright © 2011-2022 走看看