Distributed Basic Communication protocol: Paxos,totem and gossip

Source: Internet
Author: User
Tags random seed

ext.: http://blog.csdn.net/cloudresearch/article/details/23127985Background: In distributed, one of the most difficult problems to solve is the problem of data synchronization between multiple nodes. In order to solve such problems, the emergence of a variety of strange ideas. All kinds of applications can be derived only when the information synchronization is solved. Here we begin to introduce several distributed communication protocols.   Simple is effective--totem protocol: Totem protocol Maybe you are still unfamiliar, but Corosync is an open-source implementation of the Totem protocol. Compare fire ha Software pacemaker is based on Corosync to provide a variety of services. Speaking of the Totem protocol, the simplest image is that he makes multiple nodes into a token ring. Multiple nodes in hand form a circle, we pass tokens in turn. Only the node that obtains the token has the right to send the message. It is simple and effective to solve the synchronization problem of each node in the distributed system, because only one node will send the message at one time and there will be no conflict. Of course, if there is a node accident, the token ring will be broken, at this time people can not communicate, but to re-assemble a new token ring.   Evolution of the two-paragraph submission--paxos Agreement: Speaking of Paxos, need to mention a slightly two paragraph submission. In short, two-phase commit is 1. One node asks the other node if I can commit the message. 2. If you receive the consent of all, let us know and start submitting it. In practice, this Protocol does not solve the problem of information synchronization in distribution. For example, if a node fails, it will not be the result of everyone's consent, after the timeout, this time the commit failed, and so on a series of issues. However, Paxos has been optimized for the two-segment submission and has been given a better solution. The Paxos protocol introduces the concept of a majority, as well as a message number. When preparing for 1, ask 2/n+1 participants to make sure they do not accept submissions less than number n. 2. If you get a response from 2/n+1, you can start telling 2/n+1 participants to submit the message. Obviously, this is an optimized version of the two-paragraph submission. This is a more ingenious idea that solves some of the problems that come with the two-phase commit. Incidentally, the author of this agreement Leslie Lamport. He has just won the 2013 Turing Award. Fancy--GOSSIP protocol: The gossip protocol is a magical protocol. It is often used in communication protocols that mimic the spread of rumors in humans. The simple description of the protocol, the first to spread the rumor will have a seed node. The seed node randomly sends its own list of nodes to other nodes every second, along with messages that need to be propagated. Any newly added node will soon be known to the whole network in this mode of communication. The magic of this protocol is that it never thought that information must be passed on to all nodes at the beginning of the design, but as time grew, at the end of the day, the whole network will get the same information. Of course, this moment may only exist in theory and never be reached.   Basic protocol Comparison: A brief introduction to these kinds of protocols, let's look at their comparison:
Base Protocol Paxos totem gossip
Data Synchronization first stage:
  Proposer Select a proposal number n and send the prepare request to a majority in acceptors; After Acceptor receives the prepare message, If the number of the case is greater than all the prepare messages it has replied to, Acceptor will revert to proposer with his last approval and promise not to approve the proposal less than N.
Second Stage:
When a proposor receives a response from most acceptors to prepare, it enters the approval phase. It sends an accept request to the acceptors that responds to the prepare request, including the number n and the value determined by P2C (if the value is not determined by P2C, then it is free to determine value). Without violating its commitments to other proposer, Acceptor approves the request after receiving the acceptance request.
1. Means of communication.
Wait for token when the cluster has nodes to initiate communication. When you get the token, broadcast the data that needs to be sent, and then pass tokens to confirm that everyone receives the message.
If confirmation succeeds, release token.

2. Join and exit the node.
When a node joins in a cluster, the joined nodes broadcast a join message, everyone starts broadcasting their own information, and when everyone gets peer information, a token is submitted by the person with the smallest ID, which is referred to all nodes for confirmation. If the
is confirmed, the node is formally joined and starts to run normally.
when the cluster has a node exit, because the token ring broken chain, triggering token timeout, the same start broadcast information, and then by the minimum ID to submit tokens, after confirmation to return to normal. There are several implementations of the
gossip protocol, here is an example when the node starts, reads the configuration file, sends a message to a seed, synchronizes the information, and then begins to randomly select a seed node to synchronize information

1, randomly fetching a node that is currently alive , and sends it a synchronization request
2, sends a synchronization request to a randomly unreachable machine
3, sends a synchronization request to a random seed if the node selected in the first step is not seed, or if the number of nodes currently alive is less than the seed number
Data consistency Strong consistency Strong consistency Final consistency
Related applications Zookeeper Corosync Cassandra
Advantages Can be a good solution to the communication consistency problem, in the cluster size than corosync slightly larger Simple and convenient, according to the implementation of the Protocol can be directly used The protocol itself is simple, the network size is almost unlimited, the communication performance is good
Disadvantages The theory is too strong, if you want to use it, still need to optimize The use of broadcast packets has an impact on cross-domain delivery, and the problem caused by the token ring itself makes the network size small Cannot provide traditional data consistency services that consume more network traffic in transit


Paxos Reference: https://zh.wikipedia.org/wiki/Paxos%E7%AE%97%E6%B3%95

Distributed Basic Communication protocol: Paxos,totem and gossip

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.