Analysis of Paxos algorithm

Source: Internet
Author: User

https://my.oschina.net/OutOfMemory/blog/807634

Objective
In the article 2pc/3pc exactly what is introduced in the 2PC this consistency protocol, from the text to understand that 2PC more used in state consistency (distributed transactions), in data consistency is rarely used, and Paxos is in the data consistency is widely used, in the past ten years, Paxos is basically synonymous with the consistency protocol in the distributed Domain. burrows, a design developer at Google's coarse-grained Lock service chubby, once said, "all conformance agreements are inherently either Paxos or variants." Paxos's Leslielamport also won the 2013 Turing Award for his outstanding theoretical contribution to distributed SYSTEMS.
Before introducing paxos, let's start by describing what kind of data consistency is used in the scenario, as described in the copy State Machine.

Replica State machine
In distributed environment, the application scenarios of the consistency protocol are usually expressed by the replica state machine, which is an abstract representation of the different application Scenarios.
A typical mechanism for implementing a replica state machine is to use log copies, such as (source online):

Multiple servers in the cluster each save a copy of log and internal state machine, log in sequence records the operation instructions sent by the client, the server sequentially executes the instructions in log and reflect it to the internal state machine, if the log copy within each machine to ensure that the contents of the exact same, Then the corresponding state machine can also ensure that the overall state is Consistent.
The function of consistency protocol is to ensure the consistency of each log copy data, and the consistency module is used to ensure consistency.
Let's look at a more specific example: in a distributed database system, if the initial state of each node is consistent, each node executes the same sequence of operations, then they can finally get a consistent state. To ensure that each node executes the same sequence of commands, a "consistency algorithm" is executed on each instruction to ensure that the instructions seen by each node are Consistent.

democratic election algorithm


of course, There is a premise to this guarantee, which is the Byzantine question to be introduced BELOW.

Byzantine question


Non-byzantine model definition:
1. the behavior of the conformance module can be executed at any speed, allowing the run to fail, which may restart and run again after a failure;
2. The communication between the conformance modules is sent asynchronously, and the message can be arbitrarily long, and the information may be lost during Transmission. The same information is also allowed to be sent repeatedly, and the order of the multiple messages can be arbitrary. But one thing: information is not allowed to be tampered with.

the basic concept of Paxos
the first is the concept of the role of parallel processes (corresponding to the consistency module of each server on the replica state machine), and the three roles that may be assumed by different parallel processes under the Paxos protocol are as Follows:
proponents (proposer): proponents may make proposals (numerical or operational orders, etc.) for voting;
recipient (acceptor): The recipient may vote on the proposal made by the proponent and choose the only one identified from the numerous proposals;
Learner (learner): Learners have no initiative to vote, but they can learn from the recipient which proposal is ultimately chosen;
in a consistency protocol framework, a parallel process can assume the same number of roles at the same time.
after you divide the roles, you can define the problem more precisely:
1. The resolution (value) can be ratified only after it has been proposers (the non-approved resolution is called "proposal (proposal)");
2. In the execution instance of a Paxos algorithm, only one value is approved;
3.Learner can only obtain the value approved (chosen).

Paxos Conformance protocol
paxos is to achieve agreement in non-byzantine conditions when multiple parallel processes are proposing different initiatives. If you generalize the Paxos protocol, you can describe it as the following two-stage process:
Phase One: Prepare phase
1.1 "advocates perspective" The proponent chooses the initiative number n and then sends a prepare request to the majority (I.E. more than Half) of the recipient, with the initiative number n in the Request.

Phase Ii: Accept Phase
2.1 "proponents ' perspective" if the proponent receives a response from most of the recipients with respect to the prepare request with the initiative number n, the proponent sends the accept request to those recipients with two messages: the initiative number n and the initiative value v. The choice of the initiative value V is as follows: if in the 1.2 stage the recipient returns the content of the initiative with the highest initiative number acceptance request, the highest initiative number is selected from the content of these initiatives and the value of its initiative is the initiative value v; if no Recipient's Accept Request Initiative content is received at phase 1.2, you can Assign value to the initiative value v.

2.2 "recipient perspective" If the recipient receives an accept request with any initiative number n, the recipient accepts the request unless the recipient responds with a prepare request that has a higher number than N. The only value of the initiative can be selected through the above Two-stage process, which, for learners, needs to be informed by the recipient of which initiative value was Chosen. An intuitive approach is as follows: each time a recipient executes 2.2 steps, accepting an accept request, it informs all learners of the initiative they accept, so that the learner quickly learns which initiative is ultimately chosen. however, This approach leads to a lot of communication, because any recipient notifies any learner, and if there is a m-recipient, n learners, the m*n communication is Required. An alternative strategy is to select one of the many learners to be represented, to be informed of the final selected initiative from the recipient, and then to inform the other learners so that the traffic can be reduced to m+n. But in this scenario, if the Learner's representative fails, other learners have no way of knowing the value of their Initiative. Taking into account the robustness and the two factors of traffic, a compromise approach could be taken: a number of learners were selected as representatives, who were informed of the final initiative value from the recipient and then notified to other Learners.

With the above process, if there are multiple concurrent processes presenting their respective initiative values, Paxos can ensure that the replica state machine remains in a consistent state by selecting only one of the only identified initiative Values.

Summarize

This article only introduces the application scenarios of Paxos and the Paxos protocol itself, and Paxos's most difficult to understand is what causes the protocol to appear in this way and its correctness proof process rather than the final protocol itself.

Analysis of Paxos algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.