Nginx 在用于负载平衡时不会发生故障转移

发布于 2025-01-01 23:58:40 字数 382 浏览 2 评论 0原文

我们使用 Nginx 在两个上游应用程序服务器之间进行负载平衡,我们希望在部署到其中一个服务器时能够将其关闭。我们发现,当我们关闭其中一个时,Nginx 不会将故障转移到另一个。它不断发送请求并记录错误。

我们的上游指令具有以下形式:

upstream app_servers {
    server 10.100.100.100:8080;
    server 10.100.100.200:8080;
}

通过阅读 Nginx 文档,我们了解到我们不需要显式指定“max_fails”或“fail_timeout”,因为它们具有合理的默认值。 (即 max_fails 为 1)。

知道我们在这里可能会错过什么吗?

非常感谢。

We're using Nginx to load balance between two upstream app servers and we'd like to be able to take one or the other down when we deploy to it. We're finding that when we shut one down, Nginx is not failing over to the other. It keeps sending requests and logging errors.

Our upstream directive has the form:

upstream app_servers {
    server 10.100.100.100:8080;
    server 10.100.100.200:8080;
}

Our understanding from reading the Nginx docs is that we don't need to explictly specify the "max_fails" or "fail_timeout" because they have reasonable defaults. (ie. max_fails of 1).

Any idea what we might be missing here?

Thanks much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦亿 2025-01-08 23:58:40

根据文档...

max_fails = NUM​​BER - 尝试通信失败的次数
在时间段内与服务器(由参数指定)
fail_timeout),超过此时间后将被视为无效。如果没有设置,
尝试次数为一次。值为 0 会关闭此检查。什么
被认为是失败由 proxy_next_upstream 定义或
fastcgi_next_upstream(http_404 错误除外,该错误不算在内)
朝向 max_fails)。

根据文档,失败由 proxy_next_upstreamfastcgi_next_upstream

它不断发送请求并记录错误。

请检查日志记录了哪些类型的错误,如果不是默认值(错误或超时),那么您可能需要在 proxy_next_upstream 或 fastcgi_next_upstream 中专门定义它。

As per the documentation...

max_fails = NUMBER - number of unsuccessful attempts at communicating
with the server within the time period (assigned by parameter
fail_timeout) after which it is considered inoperative. If not set,
the number of attempts is one. A value of 0 turns off this check. What
is considered a failure is defined by proxy_next_upstream or
fastcgi_next_upstream (except http_404 errors which do not count
towards max_fails).

As per the documentation, a failure is define by proxy_next_upstream or fastcgi_next_upstream.

It keeps sending requests and logging errors.

Please check the log what type of errors were logged, if it is not the default (error or timeout), then you may want to define it exclusively in proxy_next_upstream or fastcgi_next_upstream.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文