Graphic distributed consistency protocol paxos

Source: Internet
Author: User

Paxos protocol/algorithm is an important protocol in Distributed Systems. How important is it?

<Distributed system transaction processing>:

Mike Burrows, author of Google chubby, said that there is only one consistent algorithm in the world, namely paxos. Other algorithms are defective.

<Large-scale distributed storage system>:

After understanding the two distributed protocols (paxos/2 PC), it is quite easy to learn other distributed protocols.

The paxos algorithm has two parts: a) Principle/proof of the algorithm; B) Understanding/operation of the algorithm.

Understanding the operation process of this algorithm can be used in engineering practice. It is easier to understand this process.

On the Internet, I think paxos is a good example of this article: paxos illustration and paxos algorithm details. Here I will further elaborate on the examples on Wiki. Some paxos basics are basically understandable through the two articles mentioned here and the content on Wiki.

Algorithm content

Paxos is simplified in the original paxos made simple:

Phase 1

(A) a proposer selects a proposal number N and sends a prepare request with number n to a majority of acceptors.

(B) If an acceptor has es a prepare request with number N greater than that of any prepare request to which it has already responded, then it responds to the request with a promise not to accept any more proposals numbered less than N and with the highest-numbered pro-posal (if any) that it has accepted.

Phase 2

(A) If the proposer has es a response to its prepare requests (numbered N) from a majority of acceptors, then it sends an accept request to each of those acceptors for a proposal numbered N with a value V, where V is the value of the highest-numbered proposal among the responses, or is any value if the responses reported no proposals.

(B) If an acceptor has es an accept request for a proposal numbered N, it accepts the proposal unless it has already responded to a prepare request having a number greater than N.

The flowchart in the paxos illustration can be summarized:

Examples and details

Paxos has three rolesProposer,AcceptorAndLearner, The main interaction process is inProposerAndAcceptor.

ProposerAndAcceptorThere are four main types of message communication, such:

These four types of messages correspond to four processes in two phases of the paxos algorithm:

  • Phase 1
    • A) Proposer sends a prepare message to more than half of the acceptor in the network.
    • B) The acceptor normally replies to the promise message.
  • Phase 2
    • A) when there are enough acceptor to reply to the promise message, the proposer sends the accept message
    • B) normally, the acceptor replies to the accepted message.

Because other proposer may send the above requests for the same thing throughout the process, there will be some special circumstances in each process, which is also done to achieve consistency. If there is no other proposer to compete in the entire process, the result of this operation is determined without objection. But if there are other proposer, the situation will be different.

Take the Chinese wiki of paxos as an example. In simple terms, this example uses several members to propose taxes and determine the final tax proportion of the bill.

In basic, only the interaction between proposer and an acceptor is drawn. The time Sign T2 is always behind T1. Propose number (n.

One of the situations is:

A3 sends an accepted to A1 at T1, receives the prepare of A5 at T2, and then A_1 notifies A5 of the final result at T3 (tax rate: 10% ). There are two cases:

  • If N5 sent from A5 is less than N1 sent from A1, A3 rejects (reject) A5 directly.
  • If N5 sent from A5 is greater than N1 sent from A1, then A3 replies to promise, but with A1 (N1, 10%)

It can be mapped to the paxos flowchart for better understanding.Acceptor records (maxn, acceptn, acceptv).

A5 after receiving promise, the subsequent process can proceed smoothly. However, when an accept is sent, the acceptv corresponding to the maximum acceptn will be obtained because (acceptn, acceptv) is received. In this example, the 10% of A1 is used as acceptv. If no other recorded acceptv is found when you receive promise, the value can be determined by yourself.

In the case of conflicts between A1 and A5, both A1 and A5 will broadcast a value of 10%.

In fact, for the acceptor, when replying to promise and accepted, special processing may be caused by the intervention of other proposer. So we can basically understand the entire algorithm when we receive requests from other proposer at these two points of time. For example, when replying to promise, it may be because the number of N sent by Proposer is not large enough and reject:

If a promise is sent to another larger N proposer when an accepted message is sent, the accept sent by the proposer will also be reject,

This corresponds to phase 2 B ):

It accepts the proposal unless it has already responded to a prepare request having a number greater than N.

Summary

Leslie Lamport didn't describe paxos in mathematics, but he explained it clearly in English. The two phase contents of paxos are clearly understood, and the entire algorithm process is still not complex.

As for the globally unique and increasing proposer number mentioned in paxos, how to implement it is referenced as follows:

How to generate a unique number? In paxos made simple, we mentioned that all proposer should be selected from different datasets. For example, the system has five proposer, each proposer can be assigned a id j (0 ~ 4), then the number of each resolution submitted by each proposer can be 5 * I + J (I can be used to indicate the number of proposals)

References
  • Paxos graphic, http://coderxy.com/archives/121
  • Paxos algorithm details, http://coderxy.com/archives/136
  • Paxos algorithm wiki, http://zh.wikipedia.org/zh-cn/Paxos%E7% AE %97%E6%B3%95#.E5. AE .9E.E4.BE.8B

Address: http://codemacro.com/2014/10/15/explain-poxos/
Written by Kevin Lynx posted athttp: // codemacro.com

Graphic distributed consistency protocol paxos

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.