V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
tinypig
V2EX  ›  Python

gevent 的一点点问题

  •  
  •   tinypig · 2013-08-22 16:10:31 +08:00 · 3846 次点击
    这是一个创建于 4113 天前的主题,其中的信息可能已经有所发展或是发生改变。
    之前看到挺多同学推荐Gunicorn+Gevent来跑Flask的,就在机子上试了一下。一个简单的flask hello world程序,发现gevent似乎没有什么提升,是因为这种测试环境没有凸显异步的优势?
    跟http://rfyiamcool.blog.51cto.com/1030776/1276364 这博文上说的结果有些不同。


    用ab -c 100 -n 2000 参数测试

    python直接启动gevent测试的负载
    ----------
    Concurrency Level: 100
    Time taken for tests: 1.651 seconds
    Complete requests: 2000
    Failed requests: 186
    (Connect: 0, Receive: 0, Length: 186, Exceptions: 0)
    Write errors: 0
    Total transferred: 285814 bytes
    HTML transferred: 25814 bytes
    Requests per second: 1211.57 [#/sec] (mean)
    Time per request: 82.537 [ms] (mean)
    Time per request: 0.825 [ms] (mean, across all concurrent requests)
    Transfer rate: 169.08 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 3 1.8 2 12
    Processing: 19 79 27.2 63 127
    Waiting: 18 78 27.5 62 127
    Total: 24 81 26.5 66 131

    Percentage of the requests served within a certain time (ms)
    50% 66
    66% 84
    75% 119
    80% 120
    90% 122
    95% 123
    98% 124
    99% 124
    100% 131 (longest request)
    ---------

    直接用gunicorn启动

    ----------------
    Concurrency Level: 100
    Time taken for tests: 1.665 seconds
    Complete requests: 2000
    Failed requests: 199
    (Connect: 0, Receive: 0, Length: 199, Exceptions: 0)
    Write errors: 0
    Total transferred: 345801 bytes
    HTML transferred: 25801 bytes
    Requests per second: 1201.11 [#/sec] (mean)
    Time per request: 83.256 [ms] (mean)
    Time per request: 0.833 [ms] (mean, across all concurrent requests)
    Transfer rate: 202.81 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 2 3.5 1 35
    Processing: 7 80 28.5 66 140
    Waiting: 7 80 28.4 66 140
    Total: 15 82 28.0 67 142

    Percentage of the requests served within a certain time (ms)
    50% 67
    66% 68
    75% 85
    80% 125
    90% 132
    95% 138
    98% 140
    99% 140
    100% 142 (longest request)
    --------------------

    使用gunicorn -k gevent方式启动

    ---------------------
    Concurrency Level: 100
    Time taken for tests: 1.939 seconds
    Complete requests: 2000
    Failed requests: 203
    (Connect: 0, Receive: 0, Length: 203, Exceptions: 0)
    Write errors: 0
    Total transferred: 345797 bytes
    HTML transferred: 25797 bytes
    Requests per second: 1031.36 [#/sec] (mean)
    Time per request: 96.959 [ms] (mean)
    Time per request: 0.970 [ms] (mean, across all concurrent requests)
    Transfer rate: 174.14 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 2 4.3 1 43
    Processing: 16 94 31.7 79 161
    Waiting: 16 93 31.7 79 161
    Total: 20 95 31.0 79 165

    Percentage of the requests served within a certain time (ms)
    50% 79
    66% 113
    75% 123
    80% 123
    90% 152
    95% 154
    98% 155
    99% 156
    100% 165 (longest request)
    --------------------
    4 条回复    1970-01-01 08:00:00 +08:00
    ipconfiger
        1
    ipconfiger  
       2013-08-22 16:15:44 +08:00   ❤️ 1
    根本就没弄清除异步的实质企图依靠弄几个所谓神器来提高性能,基本上都是水中捞月望梅止渴而已。就跟弄了本黑魔法书来念咒语,却不知道召唤出来的是神是鬼。简直无法继续吐槽了
    est
        2
    est  
       2013-08-22 16:22:27 +08:00
    @ipconfiger 货物崇拜是人的本性。淡定。
    tinypig
        3
    tinypig  
    OP
       2013-08-22 16:24:14 +08:00
    @ipconfiger 我的理解是Gevent可以在有网络延时、数据库响应的情景下提升服务器效率。但是看到有博客上有这样的测试,所以就来请教一下。
    ipconfiger
        4
    ipconfiger  
       2013-08-22 16:33:53 +08:00
    @tinypig 去工行营业厅去办个业务就能理解异步的本质了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2713 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:25 · PVG 23:25 · LAX 07:25 · JFK 10:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.