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

python redis 连接超时,可能是什么原因了?

  •  
  •   larkifly · Feb 4, 2016 · 6212 views
    This topic created in 3893 days ago, the information mentioned may be changed or developed.
    redis 的日志级别是 notice ,查看 timeout 是, redis 日志没有更新,依然是启动时的日志。

    重启 python 程序,又能连上了,中间 redis 没有做任何改动或者重启。

    redis 和 python 程序在一个内网,不同机器。
    6 replies  •  2016-02-04 15:37:17 +08:00
    aisk
        1
    aisk  
       Feb 4, 2016
    redis 当时是不是 CPU 跑满了?
    thinsky
        2
    thinsky  
       Feb 4, 2016
    可能是连接数达到上限?
    iyaozhen
        3
    iyaozhen  
       Feb 4, 2016
    应该是 redis 主动断掉了不活跃的连接。不知到你是连上 redis 进行什么操作,如果是 pub/sub 则需要在客户端连接时设置一个类似 read_timeout=-1 的东西。 PHP 的还需这样: ini_set(‘ default_socket_timeout ’, -1)。不过一般的话设置 redis timeout=0 就行了。
    mckelvin
        4
    mckelvin  
       Feb 4, 2016
    Redis 的原因,或者 Redis 到 Python 程序中间的网络原因(比如网络延迟)。

    Python 程序用的 Redis 客户端去兼容下断线重连比较好?

    另外建议给机器和 Redis 集群都加上系统指标方便查问题,比如 Redis 所在机器的 CPU, 网络, Redis 本地时延,远程时延。
    larkifly
        5
    larkifly  
    OP
       Feb 4, 2016
    @aisk cpu 内存 硬盘状态都是正常的
    larkifly
        6
    larkifly  
    OP
       Feb 4, 2016
    @iyaozhen timeout=0 这个已经设置了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2291 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 08:15 · PVG 16:15 · LAX 01:15 · JFK 04:15
    ♥ Do have faith in what you're doing.