[GO] schematic distributed conformance Protocol Paxos

Source: Internet
Author: User

Paxos Protocol/algorithm is a more important protocol in distributed system, how important is it?

< transactional processing of distributed systems;

Google Chubby Author Mikeburrows said there is only one consistency algorithm in the world, that is Paxos, the other algorithms are defective.

< large-scale distributed storage system;:

After understanding the two distributed protocols (paxos/2pc), learning about other distributed protocols can become quite easy.

The Learning Paxos algorithm has two parts: a) The principle/proof of the algorithm; b) the understanding/operation of the algorithm.

Understanding the operation of this algorithm can be used in engineering practice basically. And it's much easier to understand the process.

Online I think the Paxos to speak good belongs to this: Paxos diagram and Paxos algorithm detailed, I am here to combine the example of the wiki further elaborated. Some of the Paxos foundations are understood by the two articles mentioned here, as well as the content on the wiki.

Algorithm content

Paxos in the original author's "Paxos Made Simple" content is relatively streamlined:

Phase 1

(a) a proposer selects a proposal number N and sends a preparerequest with number N to a majority of acceptors.

(b) If an acceptor receives a prepare request with number n GreaterThan that's any prepare request to which it has alread Y Responded,then it responds to the request with a promise not to accept anymore proposals numbered less than N and with T He highest-numberedpro-posal (if any) the it has accepted.

Phase 2

(a) If the proposer receives a response to their prepare requests (numbered N) from a majority of acceptors and then it sends an Acceptrequest to all of those acceptors for a proposal numbered n with Avalue V, where V is the value of the Highest-nu Mbered Proposalamong The responses, or is any value if the responses reported noproposals.

(b) If an acceptor receives an accept request for a proposalnumbered N, it accepts the proposal unless it has already resp Ondedto a prepare request having a number greater than N.

The Paxos process can be summarized as follows:

Examples and explanations

There are three types of roles proposer, acceptor, and learner in Paxos, the main interaction between proposer and acceptor.

The interaction between proposer and acceptor consists of 4 types of message communication, such as:

These 4 types of messages correspond to the two phases of the Paxos algorithm 4 procedures:

    • Phase 1
      • A) Proposer send prepare messages to more than half of the acceptor within the network
      • b) Acceptor reply to Promise message under normal circumstances
    • Phase 2
      • A) Proposer send an accept message when there are enough acceptor to reply to promise message
      • b) Acceptor reply accepted message under normal circumstances

Because there may be other proposer in the process that make the above request for the same thing, there are special cases to be dealt with in each process, which is what is done to achieve consistency. If there is no other proposer to compete throughout the process, the result of this operation is to be sure that there is no objection. But if there were other proposer, the situation would be different.

Take the example of the Paxos Chinese wiki. In short, the example proposes a tax on a number of members to determine the percentage of the bill that is eventually passed.

Only the interaction of proposer with a acceptor is drawn in the basic. The time flag T2 is always behind T1. Proposenumber abbreviation N.

One of the situations is as follows:

A3 in T1 issued accepted to A1, and then T2 received A5 prepare in T3, A1 only notice A5 the final result (tax rate 10%). Here are two things:

    • A5 sent N5 less than A1 sent to the N1, then A3 directly refused (reject) A5
    • A5 sent N5 greater than A1 sent to the N1, then A3 reply promise, but with A1 (N1, 10%)

This can be compared with the Paxos flowchart for better understanding. acceptor will record (MAXN,ACCEPTN, ACCEPTV).

A5 after receiving the promise, the following process can be carried out smoothly. But when the accept is issued, because received (ACCEPTN,ACCEPTV), so will take the largest acceptn corresponding ACCEPTV, the example is A1 10% as ACCEPTV. If no other recorded ACCEPTV is found when promise is received, its value can be determined by itself.

In the case of the above A1 and A5 conflicts, the final A1 and A5 will broadcast the accepted value of 10%.

In fact, in the 4 process for acceptor, in the reply to promise and accepted due to other proposer intervention can lead to special treatment. So basically looking at these two points of time to receive other proposer requests can be understood the entire algorithm. For example, when replying to promise, it may be that the n proposer is not large enough to reject:

If the accepted message is sent, the proposer of the other greater n is promise, then the proposer is also reject the accept,

This corresponds to Phase 2 B):

It accepts the proposal unless it had already responded to Aprepare request had a number greater than N.

Summarize

Leslielamport did not describe Paxos mathematically, but he explained it clearly in English. The contents of Paxos's two phase are clearly understood, and the whole algorithm is not complicated.

As for a globally unique and incrementing proposer number that has been mentioned in Paxos, it is referenced as follows:

How to produce a unique number? In "Paxos madesimple" It is mentioned that all proposer are chosen from a collection of data that is never intersected, such as the system has 5 proposer, and each proposer can be assigned an identity J (0~4). Each proposer the number of each resolution may be 5*i+ J (I can be used to indicate the number of times a motion is proposed)

This section goes from the blog: http://blog.sina.com.cn/s/blog_65309a0f0102vnw5.html

[GO] schematic distributed conformance Protocol Paxos

Related Article

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.