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

请教一下大神,为什么我的 tornado 服务器性能这么低下? windows 上 jmeter 测试 centos7 虚拟机,

  •  
  •   BackToPast · 2018-07-24 20:08:28 +08:00 · 1533 次点击
    这是一个创建于 2074 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如题,windows 上 jmeter 测试 centos7 虚拟机,10 秒钟 5000 用户,90line 达到 9000ms,还有 5%的 error,代码如下:

    class IndexHandler(tornado.web.RequestHandler): # 首页请求
    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
    self.render('index.html')
    self.finish()
    3 条回复    2018-08-03 13:29:51 +08:00
    BackToPast
        1
    BackToPast  
    OP
       2018-07-24 20:14:05 +08:00
    大神~
    sujin190
        2
    sujin190  
       2018-07-26 22:48:03 +08:00
    事实上,异步的 tornado 虽然可以支持超高并发,但是受限 python 性能问题,在很高的并发情况下,会因为协程调度栈非常长,调度效率低下,因此其实并不能同时处理很多请求

    简单来说就是同时处理 5000 个请求,每个分一点时间,但是谁也无法完成
    windows 使用 select,估计 500 并发之后延迟就很高了

    还有 tornado.gen.coroutine 包裹就已经是异步了,不需要 tornado.web.asynchronous,用一个就行
    mutalisk
        3
    mutalisk  
       2018-08-03 13:29:51 +08:00
    @sujin190 windows 下默认估计不是用的 select reactor 吧,是 iocp reactor 吧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3612 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:43 · PVG 12:43 · LAX 21:43 · JFK 00:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.