客户端-服务器架构中的容错

发布于 2024-11-07 10:27:07 字数 163 浏览 0 评论 0原文

我有一个 java 服务器,它使用套接字为许多客户端提供服务 如果主服务器发生故障,我希望后台服务器自动接管。 我所做的是,我将备份服务器的 IP 地址和端口放在客户端,当发生超时时,我只是连接到备份服务器。 这是正确的决定还是我应该将备份服务器坐标放在服务器端并在连接时将其传输到客户端?

谢谢

I have a java server that serve many clients using Sockets
In case of a failure of the main server I wanted a back server to take over automaticaly.
What I did is, I put the ip address and the port of the back up server in the client side and when a timeout occure I just connect to the back up server.
Is it the right decision or I should put the backup server coordinates on the server side and transfer it to the client when it connect ?

Thanks

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

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

发布评论

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

评论(2

橘和柠 2024-11-14 10:27:07

让服务器向客户端发送备份地址是一个好主意,这样可以更轻松地集中管理这些数据。

然而,备份服务器地址也应该位于客户端上的属性文件中(或者位于客户端和服务器读取的中央配置数据库中),否则在主服务器关闭时启动时无法找到备份。

Having the server send a backup address to the client is a good idea, it is easier to administer this data centrally.

The backup server addresses should be in a property file on the client too however (or in a central configuration databse read by the clients and servers), otherwise it cannot find the backup when it starts while the primary is down.

雨后彩虹 2024-11-14 10:27:07

我认为将备份服务器信息存储在服务器上会更可靠——这样可以更轻松地更改它。如果客户端切换到备份,备份可以宣布备份的位置。

也可以使用硬件负载平衡器来处理这个问题,尽管使用无连接协议更容易。不过,使用硬件让备份机器在主服务器出现故障时自动介入当然更简单。

I suppose it would be more robust to store the backup server info on the server -- that way it could be much more easily changed. And if the client switched to the backup, the backup could announce where it's backup was.

It is possible to handle this with a hardware load-balancer, as well, although this works much more easily with connectionless protocols. It is certainly simpler, though, just to use hardware that lets the backup machine step in automatically when the main server goes down.

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