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
phuslu
V2EX  ›  Python

gevent: gunicorn vs uWSGI

  •  
  •   phuslu · 2012-10-22 10:41:19 +08:00 · 13492 次点击
    这是一个创建于 4219 天前的主题,其中的信息可能已经有所发展或是发生改变。
    http://ivan-site.com/2012/10/gevent-gunicorn-vs-uwsgi/

    推荐一下, 我觉得结果比较可信, 和我在实际项目感受的结果一致.
    也是为数不多的测试 uwsgi+gevent 性能的一个 bechmark.
    6 条回复    1970-01-01 08:00:00 +08:00
    phuslu
        1
    phuslu  
    OP
       2012-10-22 10:43:37 +08:00
    uwsgi 现在已经支持 gevent 作为 LoopEngine, 不知道大家有没有人在用
    http://projects.unbit.it/uwsgi/wiki/Gevent
    phuslu
        2
    phuslu  
    OP
       2012-10-22 10:45:17 +08:00
    最后一段作者结论, 我比较认同 :-)

    """
    As you can see, the results are pretty close with uWSGI having a slight edge in throughput in some cases and gunicorn having a slight advantage in request times. I think we can safely conclude that most of the work is being handled by gevent in this benchmark, so the server doesn’t actually play a huge role in performance. That being said, gunicorn is a lot easier to install as it doesn’t need manual compilation or beta versions of gevent.
    """
    phuslu
        3
    phuslu  
    OP
       2012-10-22 10:50:46 +08:00
    事实上, gunicorn 调用 gevent workers 的代码类似这样的原理(uwsgi+gevent 也是差不多的做法).
    http://gist.github.com/3928092
    gunicorn 是非常值得尝试的. :)
    CMGS
        4
    CMGS  
       2012-10-22 11:09:31 +08:00
    gunicorn目前在用,很“实用性”的server,相对于性能逆天的bjoern,gunicorn在提供稳定支持的情况下能最大的利用CPU和用不同Type的Worker去提升性能。uWSGI的问题在于1)源码太乱(导致bjoern出生)2)Hack的话不如Gunicorn方便。3)性能没太多亮点,一个C的和一个纯Python的几乎一致,何苦呢。

    而fapws3也有类似的问题,性能/扩展性/进程管理,这又是另外一堆内容了……

    而Gevent,也是“实用性”的异步网络层框架,理由很简单,无论是bug性能级的meinheld还是类似的eventlet,第三方库的支持很重要,而gevent这一点上做得不错,包括我们现在做的活,很容易移植一个项目基于gevent异步起来。

    至于异步是否是最优,这又是另外一段内容了……挨踢技术横竖都是回归型的……

    最后吐槽一下Gevent 1.0b4,各种坑……不要轻易尝试吧,改subprocess,fileobj,os这几个核心模块的monkey不是那么容易完成的,1.0b3相对稳定一些。
    phuslu
        5
    phuslu  
    OP
       2012-10-22 11:32:06 +08:00
    @CMGS
    嗯. bjoern/fapws3/meinheld 都不够完备, 只能算一个 wsgi server.
    gevent 就好多了, 1.0b4 多了 subprocess/fileobject 也是大势所趋.
    CMGS
        6
    CMGS  
       2012-10-22 11:34:55 +08:00
    1.0b4坑太多了……dev版本都稳定些= =
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2770 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 02:37 · PVG 10:37 · LAX 19:37 · JFK 22:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.