.net主动被动集群算法

发布于 2024-09-07 20:51:31 字数 193 浏览 4 评论 0原文

我有很多 Windows 服务器。我想在每台服务器上运行相同的 Windows 服务(用 .NET 编写)的一份副本,以便在任何时候只有其中一台服务器是“主动”的,而所有其他服务器都是被动的。如果活动 Windows 服务终止,则在很短的时间内,剩余的被动 Windows 服务中只有一个(且只有一个)会变为活动状态。

有什么简单的方法可以实现这一目标吗?

I have a number of Windows servers. I want to run one copy of the same Windows Service (written in .NET) on each of the servers such that at any one time only one of them is "active" and all the others are passive. If the active windows service dies then a very short time later one, and only one, of the remaining passive windows services becomes active.

Any ideas of simple ways to achieve this?

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

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

发布评论

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

评论(1

孤千羽 2024-09-14 20:51:31

那么,您需要使它们保持同步,最简单的方法是在数据库中的某个位置创建一个他们都可以访问的条目。让活动服务每隔几分钟更新特定行等。如果在特定时间内未找到更新,其他服务会认为活动更新已离线。当然,这里的问题是,如果数据库离线,那么服务就会出现问题,因此这可能是单点故障。不过,您也可以通过将数据库集群化来缓解这一问题。

您也可以让它们像对等网络一样相互通信,但这将需要更多工作,以获得基本相同的结果,尽管这种方法确实有其好处。

Well you need to keep them in sync, the easiest way to go would be to have an entry somewhere in a database that they can all access. Have the active service update a particular row etc. every so many minutes. If an update isn't found within a specific amount of time, the other services can take that as the active one has gone offline. Of course your problem here is that if the database goes off line, then the services will have problems, so that is potentially a single point of failure. You can alleviate this by having the db clustered as well though.

You could have them all communicate with each other like a peer to peer network too, but that will be more work, for essentially the same outcome, although this approach does have it's benefits.

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