› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
Livid
401.12D
566.87D
V2EX  ›  NGINX

交流一下,用 NGINX 反代后端运行于多个端口的 Python 程序时,大家的 max_fails 和 fail_timeout 都是怎么设的呢?

  •  
  •   Livid ·
    PRO
    · Mar 8, 2015 · 4832 views
    This topic created in 4247 days ago, the information mentioned may be changed or developed.
    3 replies  •  2015-03-09 16:02:53 +08:00
    est
        1
    est  
       Mar 8, 2015   ❤️ 2
    max_fails=0

    fail_timeout和uWSGI里harakiri 设置时间一样。

    如果是Ruby的unicorn,和 :timeout 设置一样。

    所有upstream数量x每个upstream的worker数量的fail_timeout 加起来,应该不超过 proxy_read_timeout+proxy_connect_timeout 。默认是60秒。

    也就是说,当upstream很忙的时候,nginx会挨个去尝试每个upstream,upstream会加入worker的处理队列,当这个所有处理能力都满了,nginx没有必要二次等待,直接返回504 gateway timeout算了。。。
    luw2007
        2
    luw2007  
       Mar 8, 2015   ❤️ 1
    final_timeout 理解的不对吧。 请查看 http://wiki.nginx.org/HttpUpstreamModule#server 中的解释。
    如果max_fails 为0,就不会去检查``fail_timeout``, 查看使用fail_timeout的源代码,就会异常清晰。
    <code>
    if (peer->max_fails
    && peer->fails >= peer->max_fails
    && now - peer->checked <= peer->fail_timeout)
    </code>
    est
        3
    est  
       Mar 9, 2015   ❤️ 1
    @luw2007 你说的有道理,但是假如fail_timeout设置为60s,max_fails默认为1,那么1次失败之后,这个worker就会闲置60秒。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2378 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:24 · PVG 23:24 · LAX 08:24 · JFK 11:24
    ♥ Do have faith in what you're doing.