Paxos vs Raft进行领导人选举 [英] paxos vs raft for leader election

查看:224
本文介绍了Paxos vs Raft进行领导人选举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了paxos和木筏纸之后,我有以下困惑: paxos论文仅描述了关于单个日志条目的共识,这等同于筏算法的领导者选举部分.在木筏的领导人选举中,paxos的方法比简单的随机超时方法有什么优势?

After reading paxos and raft paper, I have following confusion: paxos paper only describe consensus on single log entry, which is equivalent the leader election part of the raft algorithm. What's the advantage of paxos's approach over the simple random timeout approach in raft's leader election?

推荐答案

常见的误解是,原始Paxos论文没有使用稳定的领导者.在

It is a common misconception that the original Paxos papers don't use a stable leader. In Paxos Made Simple on page 6 in the section entitled "The Implementation" Lamport wrote:

该算法选择一个领导者,该领导者扮演 杰出的提议者和杰出的学习者.

The algorithm chooses a leader, which plays the roles of the distinguished proposer and the distinguished learner.

这是使用准备"和承诺"的第一阶段消息传递来简单实现的.

This is simply achieved using the Phase 1 messaging of prepare and promises.

然后在第9和10页的实现状态机"部分下,我们有:

Then on pages 9 and 10 under the section "Implementing a State Machine" we have:

在正常操作中,将选择一台服务器作为领导者, 充当杰出的提议者(唯一尝试 问题提案).

In normal operation, a single server is elected to be the leader, which acts as the distinguished proposer (the only one that tries to issue proposals) in all instances of the consensus algorithm.

在这里,从最一般的意义上讲,它使用的是状态机"一词,涵盖了显而易见的情况,例如键值存储或数据库服务器,我们在其中复制了应用于该存储的操作日志.

Here it is using the term 'state machine' in the most generic sense covering the obvious cases such as a key value store or database server where we replicate a log of actions applied to the store.

人们对此感到困惑,因为Lamport证明Paxos的方式已经成为现在的教学方式. Lamport通过将其简化为可以推理的数学模型,证明了称为Paxos的一类应用程序的正确性.他在原始论文

People get confused about this because of the way Lamport proved Paxos which is now the way it is taught. Lamport proved the correctness of a class of applications known as Paxos by stripping it down to a mathematical model that can be reasoned about. He called this "The Single-Decree Synod" in the original paper The Part-Time Parliament:

帕克森宗教领袖请数学家制定协议 选择主教会议的法令.协议的要求和 假设与后来的议会基本相同 总帐不是包含一系列法令,而是总帐 最多会有一项法令.产生的Synod协议是 这里描述;国会协议在第3节中进行了描述.

Paxon religious leaders asked mathematicians to formulate a protocol for choosing the Synod’s decree. The protocol’s requirements and assumptions were essentially the same as those of the later Parliament except that instead of containing a sequence of decrees, a ledger would have at most one decree. The resulting Synod protocol is described here; the Parliamentary protocol is described in Section 3.

如果您发现该陈述令人困惑,请不要担心这是一个坏笑话;字面上地.用我自己的话来说,这样的翻译是:

If you find that statement confusing don’t worry it is a bad joke; literally. A translation of this in my own words would be:

为了证明共识算法的正确性, 选择命令流,我们首先可以证明其正确性 选择单个命令的数学模型的模型.这 然后可以扩展用于选择单个命令的数学模型 选择命令流的实用算法的介绍(本节 3)只要单命令数学模型的不变量 没有受到侵犯." – simbo1905

"In order to prove the correctness of the consensus algorithm for choosing a stream of commands we can first demonstrate the correctness of a mathematical model which chooses a single command. The mathematical model for selecting a single command can then be extended to the practical algorithm for selecting a stream of commands (Section 3) as long as the invariants of the single command mathematical model are not violated." – simbo1905

为了证明我的解释的正确性,我们可以看一下标题为多法令议会"的第3节,内容为:

In order to justify my interpretation we can look at Section 3 entitled "The Multi-Decree Parliament" which says:

Paxon议会不仅通过了一项法令,还必须通过一项 系列编号法令.就像Synod协议中一样,总统是 当选.任何想要通过法令的人都会通知总统, 谁会为该法令分配一个编号并尝试通过该编号. 从逻辑上讲,议会协议使用了一个单独的 每个法令编号的完整Synod协议.但是,一个 在所有这些情况下都选择了总统,然后他执行了 该协议的前两个步骤只需一次.

Instead of passing just one decree, the Paxon Parliament had to pass a series of numbered decrees. As in the Synod protocol, a president was elected. Anyone who wanted a decree passed would inform the president, who would assign a number to the decree and attempt to pass it. Logically, the parliamentary protocol used a separate instance of the complete Synod protocol for each decree number. However, a single president was selected for all these instances, and he performed the first two steps of the protocol just once.

为解决这一点,最初的兼职议会"论文介绍了Paxos,因为它具有多级算法,因此对计算机科学家来说很有趣;议会议定书.该说明和澄清文件"Paxos变得简单"都将Paxos定义为具有杰出的领导者,可为命令流分配序列号.此外,尊贵的领导者仅在担任领导职务时才发送准备"消息;之后,在稳定状态下,杰出的领导者仅流式传输接受"消息.他还说,要在其他地方折叠角色并让所有服务器都运行算法的所有三个角色.

To labour the point both the original "The Part-Time Parliment" paper introducing Paxos as interesting to computer scientists because of its multi-degree algorithm; the parliament protocol. That and the clarification paper "Paxos Made Simple" both define Paxos as having a distinguished leader assigning sequence numbers to a stream of commands. Furthermore the distinguished leader only sends "prepare" messages when it assumes leadership; after that in steady state the distinguished leader streams only "accept" messages. He also says else where in the paper to collapse the roles and have all servers run all three roles of the algorithm.

这篇关于Paxos vs Raft进行领导人选举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆