领导者选举算法

发布于 2024-10-12 06:46:33 字数 365 浏览 12 评论 0原文

我正在探索集群计算中的各种架构。一些流行的有:

  1. 主从。
  2. RPC
  3. ...

Master-slave中,正常的做法是设置一台机器为主,一台机器为主。一堆机器作为奴隶受主人控制。这里的一个特殊算法引起了我的兴趣。它被称为Leader-Election Algo,其选择具有一定的随机性哪台机器将成为主机。

我的问题是 - 为什么有人想以这种方式选择主机?与手动选择机器作为主机相比,这种方法有什么优势?

I am exploring various architectures in cluster computing. Some of the popular ones are:

  1. Master-Slave.
  2. RPC
  3. ...

In Master-slave, the normal way is to set one machine as master & a bunch of machines as slaves controlled by master. One particular algo here got me interested. It's called Leader-Election Algo which has a certain randomness in selecting which of the machines will become master.

My question is - Why would anyone want to elect a master machine this way? What advantages does this approach have compared to manually selecting a machine as master?

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

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

发布评论

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

评论(3

当爱已成负担 2024-10-19 06:46:33

该算法有一些优点:

  1. 选择节点作为领导者将是
    动态完成,例如你
    可以选择最高的节点
    性能和新产品的到来
    节点可能会做出更好的选择。
  2. 动态的另一个好方法
    选择领导者是,如果其中之一
    节点有重大故障(例如
    电脑正在关闭)您还有其他
    选择并且没有必要
    手动更改领导者。

  3. 如果你手动选择节点应该
    手动配置所有其他节点
    使用这个节点,并设置它们的
    手动计时,...但是这个
    算法将帮助你处理
    计时问题。

  4. 例如(不是很相关)为什么
    大多数情况下使用 DHCP?太多
    配置将由此处理
    算法。

There are some advantages with this algorithms:

  1. Selection of node as leader will be
    done dynamically so for example you
    can select node with highest
    performance, and arrival of new
    nodes may be makes better choice.
  2. Another good approach by dynamically
    selecting leader is, if one of a
    nodes have major fault (for example
    PC is shutting down) you have other
    choices and there is no need to
    manually change the leader.

  3. if you manually select node should
    manually configure all other nodes
    to use this node, and also set their
    time manually, ... but this
    algorithms will help you to handle
    timing issues.

  4. for example (not very relevant) why
    in most cases using DHCP? too many
    configs will be handeled by this
    algorithms.
和我恋爱吧 2024-10-19 06:46:33

使用此类算法的主要思想是摆脱额外的配置,增加某种灵活性和整个系统的稳定性。但通常(在 HPC/MPI 应用程序中)主节点是手动选择的。

假设您的主选择算法非常简单 - 获取可用系统列表并选择具有最高 IP 地址的系统。在这种情况下,您可以轻松地在任何节点上启动一个新进程,它会自动找到主节点。

这种想法的一个很好的例子是 WCCP 协议的“指定代理”选择算法,其中代理的数量可以灵活,并且在运行时选择主节点。

Main idea of using such algorithms is to get rid of additional configuration, add some kind of flexibility, and stability of the whole system. But usually (in HPC/MPI applications) master node is selected manually.

Suppose your master selection algorithms is quite easy - get the list of available systems and select the one with the highest IP address. In this case you can easily start a new process on any of your nodes and it will automatically find the master node.

One nice example of such ideas is the WCCP protocol "designated proxy" selection algorithm where the number of proxies could be flexible and master node is selected in the runtime.

沫雨熙 2024-10-19 06:46:33

考虑到节点网络,始终拥有一个领导节点至关重要。如果当前领导者去世,那么网络必须选择另一位领导者。鉴于这种情况和要求,有两种可能的方法可以实现。

  1. 中央系统方法,有一个中央节点
    决定谁将成为领导者。如果
    现任领导去世了,那么这个
    中心节点将决定谁
    应该接任领导者的角色。
    但这是单点故障,
    这是中心节点
    负责决定领导者,
    如果当前领导者死亡,那么就没有人可以选择领导者。

  2. 在同样的场景中我们可以
    使用分布式领导者选择,如
    所有节点达成共识
    领导者应该是谁。因此,我们不需要有一个中心节点来决定谁应该是领导者,从而消除了单点故障。 时,就会有办法检测节点故障,然后每个节点都会启动分布式Leader选择算法,并相互达成选举Leader的共识。

因此,简而言之,当您有一个没有中央控制的系统时,可能是因为该系统是可扩展的而没有单点故障,在这些系统中选择某个节点时,会使用领导者选举算法。

Considering a network of nodes, where it is vital to have one leader node at all times. If the current leader dies, then the network some how has to choose another leader. Given this scenario and requirement there are two possible ways to do it.

  1. The central system approach, where there is a central node
    deciding who will be the leader. If
    the current leader dies, then this
    central node will decide on who
    should take over the leader role.
    But this is single point of failure,
    that is the central node who is
    responsible for deciding the leader,
    goes down then there is no one there to select leaders if the current leader dies.

  2. Where as in the same scenario we can
    use distributed leader selection, as
    in all the nodes come to a consensus
    who the leader should be. So we do not need to have a central node who decides on who the leader should be, hence eliminating the single point of failure. When the leader node dies, then there will be a way to detect node failure, and then every node will start a distributed leader selection algorithm, and mutually come to a consensus of electing a leader.

So, in short when you have a system which has no central control, probably because the system is meant to be scalable without having single point of failure, in those systems to take choose some node, leader elections algorithms are used.

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