推荐学习书目
› 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
mulog
V2EX  ›  Python

用 tornado 的同学 你们用 Nginx 吗

  •  
  •   mulog · Nov 18, 2014 · 6514 views
    This topic created in 4372 days ago, the information mentioned may be changed or developed.
    一直都是单进程裸跑tornado 前两天心血来潮测试了一下Nginx后面跑四个tornado
    跑hello world的话,Nginx 的 request per second 倒是可以达到单tornado的两倍多
    但是如果带上了后面的db查询 成绩基本就差不多啦 甚至还稍稍慢点

    想问问在生产环境到底要不要在tornado前面加上Nginx呢?
    如果加的话有哪些配置需要注意以提高性能?
    或者说有其他性能之外的好处?
    10 replies  •  2017-02-16 21:42:24 +08:00
    shiny
    shiny
    PRO
    Nov 18, 2014❤️1
    1
    加
    维护起来方便
    充分利用多核 CPU
    zeeler
    zeeler
    Nov 18, 2014❤️1
    2
    必须加呀,tornado跑一个实例很浪费的;另外,db查询速度和带不带nginx没啥关系,请优化db本身,比如读写分离、增加cache层、分布式等等
    kslr
    kslr
    Nov 18, 2014❤️2
    3
    一般都是多少颗CPU,就起多少实例,前面用nginx负载均衡。
    zeeler
    zeeler
    Nov 18, 2014
    4
    看下官方文档,非常建议用nginx http://unicorn.bogomips.org/PHILOSOPHY.html
    By acting as a buffer to shield unicorn from slow I/O, a reverse proxy will inevitably incur overhead in the form of extra data copies.
    .....
    nginx is the only (Free) solution we know of that meets the above requirements.
    skybr
    skybr
    Nov 18, 2014❤️1
    5
    db查询也得找异步库, tornado那个分离出去的mysql db库是block的, 而且如果要测得相对准一点, db和应用最好别放在同一个节点上.
    mulog
    mulog
    OP
    Nov 18, 2014
    6
    @skybr
    我的应用里数据库查询是一个分离出去的服务 服务调用也是异步的 所以应该没问题
    不过我也觉得是该把db放另一台机器上测试 因为我们生产环境也是这样 谢谢建议~
    msg7086
    msg7086
    Nov 18, 2014 via iPhone
    7
    Nginx解决的是慢连接问题,不是性能问题。组件变多,性能基本是会降低,所以只有在实际要解决问题的情况下才有意义增加组件。
    wwqgtxx
    wwqgtxx
    Nov 18, 2014 via Android❤️1
    8
    v2ex就是t+n的
    lianghui
    lianghui
    Nov 19, 2014
    9
    多台机器跑可以用nginx,如果一台机器直接用tornado多进程监听同一端口就行了。
    freestyle
    freestyle
    Feb 16, 2017
    10
    @skybr 请教一下适合 tornado 的异步 db 库是哪个,谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1493 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 01:20 · PVG 09:20 · LAX 17:20 · JFK 20:20
    ♥ Do have faith in what you're doing.