Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the process of paxos application?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the application process of paxos". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what is the application process of paxos" together!

examples

Below we use examples to understand the practical application process of Paxos.

Suppose we now have a distributed system with five nodes, where node A intends to propose a value of X, node E intends to propose a value of Y, and no other node proposes.

Suppose node A now broadcasts its offer (and sends it to itself). Because of network latency, only nodes A, B, and C receive it. Note that even if proposals from nodes A and E arrive at a node at the same time, they must be processed in a sequential order, where "simultaneous" is not really "simultaneous."

After A, B, and C receive the proposal, acceptedProposal and acceptedValue are both empty since this is the first proposal they receive.

Since node A has received more than half of the node responses and the returned acceptedValue is empty, that is, it can use X as the proposed value to make an Accept request. After receiving the request, A, B, and C update the acceptedValue to X.

A, B, C will occur minProposal to A, A checks that no minProposal greater than 1 occurs, and X is already selected. Wait, did we forget node D and E? Their acceptedValue is not X, and the system is still inconsistent. So far, the Paxos process isn't over yet, and we'll see.

At this point, node E selects Proposal ID 2 to send a Prepare request, and the result is different from the above, because node C has accepted node A's proposal, it will not be half-hearted, so tell node E its choice, node E is also very gentle, since C chose A's proposal, then I will choose it. So E issues an Accept request using X as the proposed value, and the entire distributed system agrees that X is chosen.

The above is a simple application process of Paxos. Other complex scenarios can also be deduced slowly according to the flowchart. Here is just a starting point.

Event development:

The first box represents the first stage--proposal.

1. p2 finds A2 first, P2 proposes serial number 2, A2 records it, because there is no other serial number before, so it succeeds, and then returns the flag to p2;

2. p1 finds A1, P1 proposes serial number 1, A1 records it, because there is no other serial number before, so it succeeds, and then returns the flag to p1;

3. p1 finds A3, P1 proposes serial number 1, A3 records it, because there is no other serial number before, so it succeeds, and then returns the flag to p1;

question is coming

4. p1 finds A2, P1 proposal serial number is 1, A2 has recorded proposal serial number 2, 2>1, so unsuccessful;

5. p2 finds A1, P2 proposal sequence number is 2, A1 has recorded proposal sequence number 1, 1>2, so success;, and then returns the flag to p2;

6. p2 finds A3, P2 proposal sequence number is 2, A3 has recorded proposal sequence number 1, 1>2, so success;, and then returns the flag to p2;

The second box represents the second stage-confirmation of the proposal (voting)

7. p1 finds A1, P1 confirms sequence number is 1, A1 has recorded proposal sequence number 2, 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report