gevent 的一点点问题 - V2EX
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 年 8 月 22 日 4254 次点击
    这是一个创建于 4529 天前的主题,其中的信息可能已经有所发展或是发生改变。
    之前看到挺多同学推荐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 年 8 月 22 日   1
    根本就没弄清除异步的实质企图依靠弄几个所谓神器来提高性能,基本上都是水中捞月望梅止渴而已。就跟弄了本黑魔法书来念咒语,却不知道召唤出来的是神是鬼。简直无法继续吐槽了
    est
        2
    est  
       2013 年 8 月 22 日
    @ipconfiger 货物崇拜是人的本性。淡定。
    tinypig
        3
    tinypig  
    OP
       2013 年 8 月 22 日
    @ipconfiger 我的理解是Gevent可以在有网络延时、数据库响应的情景下提升服务器效率。但是看到有博客上有这样的测试,所以就来请教一下。
    ipconfiger
        4
    ipconfiger  
       2013 年 8 月 22 日
    @tinypig 去工行营业厅去办个业务就能理解异步的本质了
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5668 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 22ms UTC 08:51 PVG 16:51 LAX 00:51 JFK 03:51
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86