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

最近 nginx,一直报错 recv() failed (104: Connection reset by peer) while reading response header from upstream

  •  
  •   longmeier90 · Sep 17, 2022 · 3539 views
    This topic created in 1471 days ago, the information mentioned may be changed or developed.

    最近一段时间 pad 项目打开页面一直转圈,发现后端返回也不慢,但是很多时候接收不到请求不知道为什么?

    后来跟踪日志才发现 nginx 一直提示 recv() failed (104: Connection reset by peer) while reading response header from upstream 错误。 也把 nginx 最大连接数调高了也不行。

    6 replies  •  2022-09-19 13:59:04 +08:00
    knightdf
        1
    knightdf  
       Sep 17, 2022
    看后端有没有报错和其他超时
    fggz
        2
    fggz  
       Sep 17, 2022
    +1 一直报这个,还有 502 ,不过业务好像没有影响,一直没有找到原因。
    eason1874
        3
    eason1874  
       Sep 17, 2022
    这种情况只调 nginx 没用,因为也有可能是后端重置的
    cz5424
        5
    cz5424  
       Sep 18, 2022
    @corvofeng 我折腾了两天,发现了跟你同样的问题,我是盲猜 1.1 会 keepalive ,如果到 tcp timeout 就会把链接掐了,掐了的时候就返回 502
    longmeier90
        6
    longmeier90  
    OP
       Sep 19, 2022
    =============这是我的解决方案===========
    1. [后端] nginx 连接数调高、buffer 缓存调大、keepalive 加了长连接
    2. [后端] 增加后台服务进程数
    3. [后端] 慢接口进行读写分离优化(分析错误日志,找到转圈时刻慢接口)
    4. [后端] 增加自动访问接口提醒功能(每分钟)
    5. [后端] 增加了调第三方服务超时时间
    6. [前端] 优化了超时时间 30 秒改 10 秒
    7. [前端] 优化了页面快速切换的重复请求
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   833 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 22:26 · PVG 06:26 · LAX 15:26 · JFK 18:26
    ♥ Do have faith in what you're doing.