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

Python 2.7 Gunicorn + Flask,有大量的第三方服务 http 请求, requests 库阻塞导致出现性能瓶颈

  •  3
     
  •   woostundy · Aug 15, 2017 · 17779 views
    This topic created in 3366 days ago, the information mentioned may be changed or developed.
    该怎么优化呢?异步 http 客户端的库哪个比较靠谱?
    Supplement 1  ·  Aug 16, 2017
    多谢各位帮忙,我觉得有必要重新描述一下问题:
    现在有服务 A 和服务 B,服务 A 有一部分数据库读写操作,同时每次都会通过 requests 访问服务 B (每次都只会访问一次,B 服务性能完全足够)
    服务 A 的结构是 Flask + Gunicorn + Gevent,当 A 服务器 QPS 到 50 时,数据库访问没有压力,但会出现 requests 到服务 B 的速度变慢甚至超时。

    不是 A 一次请求内多次请求 B 服务,而是每次 A 都会请求一次 B,所以设置 session 共享 tcp 连接( keep-alive )应该是无效的。
    101 replies  •  2017-08-26 13:08:33 +08:00
    1  2  
    ❮ ❯
    justff
    justff
    Aug 26, 2017 via Android
    101
    同意楼上 加上 io 密集条件更接近实战
    1  2  
    ❮ ❯
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1580 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 23:08 · PVG 07:08 · LAX 15:08 · JFK 18:08
    ♥ Do have faith in what you're doing.