跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 关于 nginx 中 proxy_next_upstream 与 max_fails 之间的关系,求解
未分類
27 3 月 2021

关于 nginx 中 proxy_next_upstream 与 max_fails 之间的关系,求解

关于 nginx 中 proxy_next_upstream 与 max_fails 之间的关系,求解

資深大佬 : jarry118 10

我理解的:upstream 中 max_fails 对应的 fail 类型,是由参数 proxy_next_upstream error 来定义的,比如 proxy_next_upstream error timeout http_500 http_502 http_503 http_504; 表示定义了超时、500 、502 、503 、504 请求为 fail 状态。

第一种场景:

proxy_next_upstream error timeout http_500 http_502 http_503 http_504; proxy_next_upstream_tries 3;  upstream test {         server ip1:8080 weight=10 max_fails=2 fail_timeout=30s;         server ip2:8080 weight=10 max_fails=2 fail_timeout=30s;          keepalive 200; } 

表示后台 server 在 30s 内如果失败两次(fail 类型包括超时、500 、502 、503 、504 请求),会重试 3 次请求这个后台 server,如果 3 次还是失败,则将这个 server 节点 down,请求到其他的 server 节点。

第二种场景:

proxy_next_upstream off; proxy_next_upstream_tries 3;  upstream test {         server ip1:8080 weight=10 max_fails=2 fail_timeout=30s;         server ip2:8080 weight=10 max_fails=2 fail_timeout=30s;          keepalive 200; } 

此时 max_fails 不生效,server 发生问题时,该 server 后续还是会继续收到请求。

这里有个问题,如果设置为 proxy_next_upstream error,会发现第二种场景的情况吗?

大佬有話說 (3)

  • 資深大佬 : Judoon

    取决于 “server 发生问题”,是具体什么问题吧,根据文档 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream

  • 資深大佬 : Judoon

    error 表示建立连接失败,或者连接后收不到响应等,是协议连接层面的问题。
    如果你的 server 给了个 500,那 nginx 就不会认为 server 是 down 的状态,当然继续发送

  • 主 資深大佬 : jarry118

    @Judoon 感谢,学习了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具