mod_proxy 超时 (502) 和故障转移

发布于 2024-07-20 07:12:14 字数 771 浏览 3 评论 0原文

因此,我们正在运行一个由 2 个以上后端服务器(恰好是 JBoss 服务器)组成的集群,这些服务器由 Apache 2.2 进行负载平衡。 有时,后端服务器可能会变得无响应(这意味着它们将等待很长时间才能回复请求,但不会立即关闭连接)。 这自然会导致 502“Bad gateway”错误。 我对负载均衡器的理解是,它应该进行故障转移并将请求重定向到其余实例。

我已经看到平衡器的节点可以进入错误状态,但永远无法强制将其发送到该状态(即在遇到第一个 502 后执行此操作)。 我错过了什么还是这只是我想要的功能? 哦,这是我的配置:

<Proxy balancer://s>
    Order deny,allow
    Allow from all

    BalancerMember http://host1:8080/ route=h1 timeout=20 retry=40
    BalancerMember http://host2:8080/ route=h2 timeout=20 retry=40
</Proxy>

# Distribute by Round Robin, use Sticky Sessions
ProxyPass / balancer://s/ stickysession=JSESSIONID lbmethod=byrequests nofailover=On
ProxyPassReverse /  http://host1:8080/
ProxyPassReverse /  http://host2:8080/

最好, 塞巴斯蒂安

so we're running a cluster of 2+ backend servers (happend to be JBoss servers) that are being load-balanced by an Apache 2.2. From time to time it can happen that the backend servers become unresponsive (meaning they'll wait ages to reply to a request, but don't close the connection immediately). This will naturally end up in a 502 "Bad gateway" error. My understanding of a load-balancer that is, that it should fail-over and redirect requests to the remaining instances.

I've seen that a node of the balancer can go to error state, but was never able to force-fully send one into that state (i.e. do that after the first 502 has been encountered). Am I missing something or is that just a feature I am wishing for?
Oh, and here goes my config:

<Proxy balancer://s>
    Order deny,allow
    Allow from all

    BalancerMember http://host1:8080/ route=h1 timeout=20 retry=40
    BalancerMember http://host2:8080/ route=h2 timeout=20 retry=40
</Proxy>

# Distribute by Round Robin, use Sticky Sessions
ProxyPass / balancer://s/ stickysession=JSESSIONID lbmethod=byrequests nofailover=On
ProxyPassReverse /  http://host1:8080/
ProxyPassReverse /  http://host2:8080/

Best,
Sebastian

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

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

发布评论

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

评论(1

相思碎 2024-07-27 07:12:14

您指定 nofailover=On 这意味着它不会进行故障转移,因此会出现 502 错误。 如果您希望它进行故障转移,则需要设置 nofailover=Off 这意味着它应该进行故障转移。

You specified nofailover=On which means it won't failover, hence the 502 errors. If you want it to failover it needs to be nofailover=Off which means it should failover.

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