V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Livid
V2EX  ›  NGINX

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

  •  
  •   Livid · 2015-03-08 09:42:08 +08:00 · 4038 次点击
    这是一个创建于 3339 天前的主题,其中的信息可能已经有所发展或是发生改变。
    3 条回复    2015-03-09 16:02:53 +08:00
    est
        1
    est  
       2015-03-08 12:00:10 +08:00   ❤️ 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  
       2015-03-08 23:23:29 +08:00   ❤️ 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  
       2015-03-09 16:02:53 +08:00   ❤️ 1
    @luw2007 你说的有道理,但是假如fail_timeout设置为60s,max_fails默认为1,那么1次失败之后,这个worker就会闲置60秒。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3379 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 00:42 · PVG 08:42 · LAX 17:42 · JFK 20:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.