词条 | Paxos (computer science) | ||||||||||||||
释义 |
Paxos is a family of protocols for solving consensus in a network of unreliable processors (that is, processors that may fail). Consensus is the process of agreeing on one result among a group of participants. This problem becomes difficult when the participants or their communication medium may experience failures. Consensus protocols are the basis for the state machine replication approach to distributed computing, as suggested by Leslie Lamport[2] and surveyed by Fred Schneider.[3] State machine replication is a technique for converting an algorithm into a fault-tolerant, distributed implementation. Ad-hoc techniques may leave important cases of failures unresolved. The principled approach proposed by Lamport et al. ensures all cases are handled safely. The Paxos protocol was first published in 1989 and named after a fictional legislative consensus system used on the Paxos island in Greece.[4] It was later published as a journal article in 1998.[5] The Paxos family of protocols includes a spectrum of trade-offs between the number of processors, number of message delays before learning the agreed value, the activity level of individual participants, number of messages sent, and types of failures. Although no deterministic fault-tolerant consensus protocol can guarantee progress in an asynchronous network (a result proved in a paper by Fischer, Lynch and Paterson[6]), Paxos guarantees safety (consistency), and the conditions that could prevent it from making progress are difficult to provoke. Paxos is usually used where durability is required (for example, to replicate a file or a database), in which the amount of durable state could be large. The protocol attempts to make progress even during periods when some bounded number of replicas are unresponsive. There is also a mechanism to drop a permanently failed replica or to add a new replica. HistoryThe topic predates the protocol. In 1988, Lynch, Dwork and Stockmeyer had demonstrated [7] the solvability of consensus in a broad family of "partially synchronous" systems. Paxos has strong similarities to a protocol used for agreement in viewstamped replication, first published by Oki and Liskov in 1988, in the context of distributed transactions.[8] Notwithstanding this prior work, Paxos offered a particularly elegant formalism, and included one of the earliest proofs of safety for a fault-tolerant distributed consensus protocol. Reconfigurable state machines have strong ties to prior work on reliable group multicast protocols that support dynamic group membership, for example Birman's work in 1985 and 1987 on the virtually synchronous gbcast[9] protocol. However, it should be noted that gbcast is unusual in supporting durability and addressing partitioning failures. Most reliable multicast protocols lack these properties, which are required for implementations of the state machine replication model. This point is elaborated in a paper by Lamport, Malkhi and Zhou.[10] AssumptionsIn order to simplify the presentation of Paxos, the following assumptions and definitions are made explicit. Techniques to broaden the applicability are known in the literature, and are not covered in this article. Processors
Network
Number of processorsIn general, a consensus algorithm can make progress using processors, despite the simultaneous failure of any processors [11]: in other words, the number of non-faulty processes must be strictly greater than the number of faulty processes. However, using reconfiguration, a protocol may be employed which survives any number of total failures as long as no more than F fail simultaneously{{citation needed|date=November 2018}}. RolesPaxos describes the actions of the processors by their roles in the protocol: client, acceptor, proposer, learner, and leader. In typical implementations, a single processor may play one or more roles at the same time. This does not affect the correctness of the protocol—it is usual to coalesce roles to improve the latency and/or number of messages in the protocol.
QuorumsQuorums express the safety (or consistency) properties of Paxos by ensuring at least some surviving processor retains knowledge of the results. Quorums are defined as subsets of the set of Acceptors such that any two subsets (that is, any two Quorums) share at least one member. Typically, a Quorum is any majority of participating Acceptors. For example, given the set of Acceptors {A,B,C,D}, a majority Quorum would be any three Acceptors: {A,B,C}, {A,C,D}, {A,B,D}, {B,C,D}. More generally, arbitrary positive weights can be assigned to Acceptors; in that case, a Quorum can be defined as any subset of Acceptors with the summary weight greater than half of the total weight of all Acceptors. Proposal Number & Agreed ValueEach attempt to define an agreed value v is performed with proposals which may or may not be accepted by Acceptors. Each proposal is uniquely numbered for a given Proposer. So, e.g., each proposal may be of the form (n, v), where n is the unique identifier of the proposal and v is the actual proposed value. The value corresponding to a numbered proposal can be computed as part of running the Paxos protocol, but need not be. Safety and liveness propertiesIn order to guarantee safety (also called "consistency"), Paxos defines three properties and ensures they are always held, regardless of the pattern of failures:
Typical deploymentIn most deployments of Paxos, each participating process acts in three roles; Proposer, Acceptor and Learner.[16] This reduces the message complexity significantly, without sacrificing correctness: {{cquote|In Paxos, clients send commands to a leader. During normal operation, the leader receives a client's command, assigns it a new command number i, and then begins the ith instance of the consensus algorithm by sending messages to a set of acceptor processes.[14]}}By merging roles, the protocol "collapses" into an efficient client-master-replica style deployment, typical of the database community. The benefit of the Paxos protocols (including implementations with merged roles) is the guarantee of its safety properties. A typical implementation's message flow is covered in the section Multi-Paxos. Basic PaxosThis protocol is the most basic of the Paxos family. Each "instance" (or "execution") of the basic Paxos protocol decides on a single output value. The protocol proceeds over several rounds. A successful round has 2 phases: phase 1 (which is divided into parts a and b) and phase 2 (which is divided into parts a and b). See below the description of the phases. Remember that, we assume an asynchronous model; so, e.g., a processor may be in one phase, while another may be in another. Phase 1Phase 1a: PrepareA Proposer creates a message, which we call a "Prepare", identified with a number n. Note that n is not the value to be proposed and maybe agreed on, but just a number which uniquely identifies this initial message by the proposer (to be sent to the acceptors). The number n must be greater than any number used in any of the previous Prepare messages by this Proposer. Then, it sends the Prepare message containing n to a Quorum of Acceptors. Note that the Prepare message only contains the number n (that is, it does not have to contain e.g. the proposed value, often denoted by v). The Proposer decides who is in the Quorum{{how|date=October 2018}}. A Proposer should not initiate Paxos if it cannot communicate with at least a Quorum of Acceptors. Phase 1b: PromiseAny of the Acceptors waits for a Prepare message from any of the Proposers. If an Acceptor receives a Prepare message, the Acceptor must look at the identifier number n of the just received Prepare message. There are two cases. If n is higher than every previous proposal number received, from any of the Proposers, by the Acceptor, then the Acceptor must return a message, which we call a "Promise", to the Proposer, to ignore all future proposals having a number less than n. If the Acceptor accepted a proposal at some point in the past, it must include the previous proposal number, say m, and the corresponding accepted value, say w, in its response to the Proposer. Otherwise (that is, n is less than or equal to any previous proposal number received from any Proposer by the Acceptor) the Acceptor can ignore the received proposal. It does not have to answer in this case for Paxos to work. However, for the sake of optimization, sending a denial (Nack) response would tell the Proposer that it can stop its attempt to create consensus with proposal n. Phase 2Phase 2a: AcceptIf a Proposer receives enough Promises{{how many|date=October 2018}} from a Quorum of Acceptors, it needs to set a value v to its proposal. If any Acceptors had previously accepted any proposal, then they'll have sent their values to the Proposer, who now must set the value of its proposal, v, to the value associated with the highest proposal number reported by the Acceptors, let's call it z. If none of the Acceptors had accepted a proposal up to this point, then the Proposer may choose the value it originally wanted to propose, say x[18]. The Proposer sends an Accept message, (n, v), to a Quorum of Acceptors with the chosen value for its proposal, v, and the proposal number n (which is the same as the number contained in the Prepare message previously sent to the Acceptors). So, the Accept message is either (n, v=z) or, in case none of the Acceptors previously accepted a value, (n, v=x). This Accept message should be interpreted as a "request", as in "Accept this proposal, please!". Phase 2b: AcceptedIf an Acceptor receives an Accept message, (n, v), from a Proposer, it must accept it if and only if it has not already promised (in Phase 1b of the Paxos protocol) to only consider proposals having an identifier greater than n. If the Acceptor has not already promised (in Phase 1b) to only consider proposals having an identifier greater than n, it should register the value v (of the just received Accept message) as the accepted value (of the Protocol), and send an Accepted message to the Proposer and every Learner (which can typically be the Proposers themselves). Else, it can ignore the Accept message or request. Note that an Acceptor can accept multiple proposals. This can happen when another Proposer, unaware of the new value being decided, starts a new round with a higher identification number n. In that case, the Acceptor can promise and later accept the new proposed value even though it has accepted another one earlier. These proposals may even have different values in the presence of certain failures{{example needed|date=October 2018}}. However, the Paxos protocol will guarantee that the Acceptors will ultimately agree on a single value. When Rounds FailRounds fail when multiple Proposers send conflicting Prepare messages, or when the Proposer does not receive a Quorum of responses (Promise or Accepted). In these cases, another round must be started with a higher proposal number. Paxos can be used to select a leaderNotice that when Acceptors accept a request, they also acknowledge the leadership of the Proposer{{how|reason=It is not explained above this|date=October 2018}}. Hence, Paxos can be used to select a leader in a cluster of nodes{{clarify|reason=It is not clear how Paxos can be used to select a leader from these explanations.|date=October 2018}}. Graphic representation of the flow of messages in the basic PaxosThe following diagrams represent several cases/situations of the application of the Basic Paxos protocol. Some cases show how the Basic Paxos protocol copes with the failure of certain (redundant) components of the distributed system. Note that the values returned in the Promise message are "null" the first time a proposal is made (since no Acceptor has accepted a value before in this round). Basic Paxos without failuresIn the diagram below, there is 1 Client, 1 Proposer, 3 Acceptors (i.e. the Quorum size is 3) and 2 Learners (represented by the 2 vertical lines). This diagram represents the case of a first round, which is successful (i.e. no process in the network fails). Client Proposer Acceptor Learner | | | | | | | X-------->| | | | | | Request | X--------->|->|->| | | Prepare(1) | |<---------X--X--X | | Promise(1,{Va,Vb,Vc}) | X--------->|->|->| | | Accept!(1,V) | |<---------X--X--X------>|->| Accepted(1,V) |<---------------------------------X--X Response | | | | | | | Here, V is the last of (Va, Vb, Vc). Error cases in basic PaxosThe simplest error cases are the failure of an Acceptor (when a Quorum of Acceptors remains alive) and failure of a redundant Learner. In these cases, the protocol requires no "recovery" (i.e. it still succeeds): no additional rounds or messages are required, as shown below (in the next two diagrams/cases). Basic Paxos when an Acceptor failsIn the following diagram, one of the Acceptors in the Quorum fails, so the Quorum size becomes 2. In this case, the Basic Paxos protocol still succeeds. Client Proposer Acceptor Learner | | | | | | | X-------->| | | | | | Request | X--------->|->|->| | | Prepare(1) | | | | ! | | !! FAIL !! | |<---------X--X | | Promise(1,{Va, Vb, null}) | X--------->|->| | | Accept!(1,V) | |<---------X--X--------->|->| Accepted(1,V) |<---------------------------------X--X Response | | | | | | Basic Paxos when a redundant learner failsIn the following case, one of the (redundant) Learners fails, but the Basic Paxos protocol still succeeds. Client Proposer Acceptor Learner | | | | | | | X-------->| | | | | | Request | X--------->|->|->| | | Prepare(1) | |<---------X--X--X | | Promise(1,{Va,Vb,Vc}) | X--------->|->|->| | | Accept!(1,V) | |<---------X--X--X------>|->| Accepted(1,V) | | | | | | ! !! FAIL !! |<---------------------------------X Response | | | | | | Basic Paxos when a Proposer failsIn this case, a Proposer fails after proposing a value, but before the agreement is reached. Specifically, it fails in the middle of the Accept message, so only one Acceptor of the Quorum receives the value. Meanwhile, a new Leader (a Proposer) is elected (but this is not shown in detail). Note that there are 2 rounds in this case (rounds proceed vertically, from the top to the bottom). Client Proposer Acceptor Learner | | | | | | | X----->| | | | | | Request | X------------>|->|->| | | Prepare(1) | |<------------X--X--X | | Promise(1,{Va, Vb, Vc}) | | | | | | | | | | | | | | !! Leader fails during broadcast !! | X------------>| | | | | Accept!(1,V) | ! | | | | | | | | | | | | !! NEW LEADER !! | X--------->|->|->| | | Prepare(2) | |<---------X--X--X | | Promise(2,{V, null, null}) | X--------->|->|->| | | Accept!(2,V) | |<---------X--X--X------>|->| Accepted(2,V) |<---------------------------------X--X Response | | | | | | | Basic Paxos when multiple Proposers conflictThe most complex case is when multiple Proposers believe themselves to be Leaders. For instance, the current leader may fail and later recover, but the other Proposers have already re-selected a new leader. The recovered leader has not learned this yet and attempts to begin one round in conflict with the current leader. In the diagram below, 4 unsuccessful rounds are shown, but there could be more (as suggested at the bottom of the diagram). Client Leader Acceptor Learner | | | | | | | X----->| | | | | | Request | X------------>|->|->| | | Prepare(1) | |<------------X--X--X | | Promise(1,{null,null,null}) | ! | | | | | !! LEADER FAILS | | | | | | | !! NEW LEADER (knows last number was 1) | X--------->|->|->| | | Prepare(2) | |<---------X--X--X | | Promise(2,{null,null,null}) | | | | | | | | !! OLD LEADER recovers | | | | | | | | !! OLD LEADER tries 2, denied | X------------>|->|->| | | Prepare(2) | |<------------X--X--X | | Nack(2) | | | | | | | | !! OLD LEADER tries 3 | X------------>|->|->| | | Prepare(3) | |<------------X--X--X | | Promise(3,{null,null,null}) | | | | | | | | !! NEW LEADER proposes, denied | | X--------->|->|->| | | Accept!(2,Va) | | |<---------X--X--X | | Nack(3) | | | | | | | | !! NEW LEADER tries 4 | | X--------->|->|->| | | Prepare(4) | | |<---------X--X--X | | Promise(4,{null,null,null}) | | | | | | | | !! OLD LEADER proposes, denied | X------------>|->|->| | | Accept!(3,Vb) | |<------------X--X--X | | Nack(4) | | | | | | | | ... and so on ... Multi-PaxosA typical deployment of Paxos requires a continuous stream of agreed values acting as commands to a distributed state machine. If each command is the result of a single instance of the Basic Paxos protocol, a significant amount of overhead would result. If the leader is relatively stable, phase 1 becomes unnecessary. Thus, it is possible to skip phase 1 for future instances of the protocol with the same leader. To achieve this, the round number I is included along with each value which is incremented in each round by the same Leader. Multi-Paxos reduces the failure-free message delay (proposal to learning) from 4 delays to 2 delays. Graphic representation of the flow of messages in the Multi-PaxosMulti-Paxos without failuresIn the following diagram, only one instance (or "execution") of the basic Paxos protocol, with an initial Leader (a Proposer), is shown. Note that a Multi-Paxos consists of several instances of the basic Paxos protocol. Client Proposer Acceptor Learner | | | | | | | --- First Request --- X-------->| | | | | | Request | X--------->|->|->| | | Prepare(N) | |<---------X--X--X | | Promise(N,I,{Va,Vb,Vc}) | X--------->|->|->| | | Accept!(N,I,V) | |<---------X--X--X------>|->| Accepted(N,I,V) |<---------------------------------X--X Response | | | | | | | where V = last of (Va, Vb, Vc). Multi-Paxos when phase 1 can be skippedIn this case, subsequence instances of the basic Paxos protocol (represented by I+1) use the same leader, so the phase 1 (of these subsequent instances of the basic Paxos protocol), which consist in the Prepare and Promise sub-phases, is skipped. Note that the Leader should be stable, i.e. it should not crash or change. Client Proposer Acceptor Learner | | | | | | | --- Following Requests --- X-------->| | | | | | Request | X--------->|->|->| | | Accept!(N,I+1,W) | |<---------X--X--X------>|->| Accepted(N,I+1,W) |<---------------------------------X--X Response | | | | | | | Multi-Paxos when roles are collapsedA common deployment of the Multi-Paxos consists in collapsing the role of the Proposers, Acceptors and Learners to "Servers". So, in the end, there are only "Clients" and "Servers". The following diagram represents the first "instance" of a basic Paxos protocol, when the roles of the Proposer, Acceptor and Learner are collapsed to a single role, called the "Server". Client Servers | | | | --- First Request --- X-------->| | | Request | X->|->| Prepare(N) | |<-X--X Promise(N, I, {Va, Vb}) | X->|->| Accept!(N, I, Vn) | X<>X<>X Accepted(N, I) |<--------X | | Response | | | | Multi-Paxos when roles are collapsed and the leader is steadyIn the subsequent instances of the basic Paxos protocol, with the same leader as in the previous instances of the basic Paxos protocol, the phase 1 can be skipped. Client Servers X-------->| | | Request | X->|->| Accept!(N,I+1,W) | X<>X<>X Accepted(N,I+1) |<--------X | | Response | | | | OptimizationsA number of optimisations can be performed to reduce the number of exchanged messages, to improve the performance of the protocol, etc. A few of these optimisations are reported below. "We can save messages at the cost of an extra message delay by having a single distinguished learner that informs the other learners when it finds out that a value has been chosen. Acceptors then send Accepted messages only to the distinguished learner. In most applications, the roles of leader and distinguished learner are performed by the same processor. [19] "A leader can send its Prepare and Accept! messages just to a quorum of acceptors. As long as all acceptors in that quorum are working and can communicate with the leader and the learners, there is no need for acceptors not in the quorum to do anything. [19] "Acceptors do not care what value is chosen. They simply respond to Prepare and Accept! messages to ensure that, despite failures, only a single value can be chosen. However, if an acceptor does learn what value has been chosen, it can store the value in stable storage and erase any other information it has saved there. If the acceptor later receives a Prepare or Accept! message, instead of performing its Phase1b or Phase2b action, it can simply inform the leader of the chosen value. [19] "Instead of sending the value v, the leader can send a hash of v to some acceptors in its Accept! messages. A learner will learn that v is chosen if it receives Accepted messages for either v or its hash from a quorum of acceptors, and at least one of those messages contains v rather than its hash. However, a leader could receive Promise messages that tell it the hash of a value v that it must use in its Phase2a action without telling it the actual value of v. If that happens, the leader cannot execute its Phase2a action until it communicates with some process that knows v."[19] "A proposer can send its proposal only to the leader rather than to all coordinators. However, this requires that the result of the leader-selection algorithm be broadcast to the proposers, which might be expensive. So, it might be better to let the proposer send its proposal to all coordinators. (In that case, only the coordinators themselves need to know who the leader is.) [12] "Instead of each acceptor sending Accepted messages to each learner, acceptors can send their Accepted messages to the leader and the leader can inform the learners when a value has been chosen. However, this adds an extra message delay. [12] "Finally, observe that phase 1 is unnecessary for round 1 .. The leader of round 1 can begin the round by sending an Accept! message with any proposed value."[12] Cheap PaxosCheap Paxos extends Basic Paxos to tolerate F failures with F+1 main processors and F auxiliary processors by dynamically reconfiguring after each failure. This reduction in processor requirements comes at the expense of liveness; if too many main processors fail in a short time, the system must halt until the auxiliary processors can reconfigure the system. During stable periods, the auxiliary processors take no part in the protocol. "With only two processors p and q, one processor cannot distinguish failure of the other processor from failure of the communication medium. A third processor is needed. However, that third processor does not have to participate in choosing the sequence of commands. It must take action only in case p or q fails, after which it does nothing while either p or q continues to operate the system by itself. The third processor can therefore be a small/slow/cheap one, or a processor primarily devoted to other tasks."[19] Message flow: Cheap Multi-PaxosAn example involving three main acceptors, one auxiliary acceptor and quorum size of three, showing failure of one main processor and subsequent reconfiguration: { Acceptors }Proposer Main Aux Learner| | | | | | -- Phase 2 --X----------->|->|->| | | Accept!(N,I,V)| | | ! | | --- FAIL! ---|<-----------X--X--------------->| Accepted(N,I,V)| | | | | -- Failure detected (only 2 accepted) --X----------->|->|------->| | Accept!(N,I,V) (re-transmit, include Aux)|<-----------X--X--------X------>| Accepted(N,I,V)| | | | | -- Reconfigure : Quorum = 2 --X----------->|->| | | Accept!(N,I+1,W) (Aux not participating)|<-----------X--X--------------->| Accepted(N,I+1,W)| | | | | Fast PaxosFast Paxos generalizes Basic Paxos to reduce end-to-end message delays. In Basic Paxos, the message delay from client request to learning is 3 message delays. Fast Paxos allows 2 message delays, but requires that (1) the system be comprised by 3f+ 1 acceptors to tolerate up to f faults (instead of the classic 2f+1), and (2) the Client to send its request to multiple destinations. Intuitively, if the leader has no value to propose, then a client could send an Accept! message to the Acceptors directly. The Acceptors would respond as in Basic Paxos, sending Accepted messages to the leader and every Learner achieving two message delays from Client to Learner. If the leader detects a collision, it resolves the collision by sending Accept! messages for a new round which are Accepted as usual. This coordinated recovery technique requires four message delays from Client to Learner. The final optimization occurs when the leader specifies a recovery technique in advance, allowing the Acceptors to perform the collision recovery themselves. Thus, uncoordinated collision recovery can occur in three message delays (and only two message delays if all Learners are also Acceptors). Message flow: Fast Paxos, non-conflictingClient Leader Acceptor Learner | | | | | | | | | X--------->|->|->|->| | | Any(N,I,Recovery) | | | | | | | | X------------------->|->|->|->| | | Accept!(N,I,W) | |<---------X--X--X--X------>|->| Accepted(N,I,W) |<------------------------------------X--X Response(W) | | | | | | | | Message flow: Fast Paxos, conflicting proposalsConflicting proposals with coordinated recovery. Note: the protocol does not specify how to handle the dropped client request.Client Leader Acceptor Learner | | | | | | | | | | | | | | | | | | | | | | | | | | | !! Concurrent conflicting proposals | | | | | | | | | !! received in different order | | | | | | | | | !! by the Acceptors | X--------------?|-?|-?|-?| | | Accept!(N,I,V) X-----------------?|-?|-?|-?| | | Accept!(N,I,W) | | | | | | | | | | | | | | | | | | !! Acceptors disagree on value | | |<-------X--X->|->|----->|->| Accepted(N,I,V) | | |<-------|<-|<-X--X----->|->| Accepted(N,I,W) | | | | | | | | | | | | | | | | | | !! Detect collision & recover | | X------->|->|->|->| | | Accept!(N+1,I,W) | | |<-------X--X--X--X----->|->| Accepted(N+1,I,W) |<---------------------------------X--X Response(W) | | | | | | | | |Conflicting proposals with uncoordinated recovery. Client Leader Acceptor Learner | | | | | | | | | | | X------->|->|->|->| | | Any(N,I,Recovery) | | | | | | | | | | | | | | | | | | !! Concurrent conflicting proposals | | | | | | | | | !! received in different order | | | | | | | | | !! by the Acceptors | X--------------?|-?|-?|-?| | | Accept!(N,I,V) X-----------------?|-?|-?|-?| | | Accept!(N,I,W) | | | | | | | | | | | | | | | | | | !! Acceptors disagree on value | | |<-------X--X->|->|----->|->| Accepted(N,I,V) | | |<-------|<-|<-X--X----->|->| Accepted(N,I,W) | | | | | | | | | | | | | | | | | | !! Detect collision & recover | | |<-------X--X--X--X----->|->| Accepted(N+1,I,W) |<---------------------------------X--X Response(W) | | | | | | | | | Message flow: Fast Paxos with uncoordinated recovery, collapsed roles(merged Acceptor/Learner roles)Client Servers | | | | | | | | X->|->|->| Any(N,I,Recovery) | | | | | | | | | | | | !! Concurrent conflicting proposals | | | | | | !! received in different order | | | | | | !! by the Servers | X--------?|-?|-?|-?| Accept!(N,I,V) X-----------?|-?|-?|-?| Accept!(N,I,W) | | | | | | | | | | | | !! Servers disagree on value | | X<>X->|->| Accepted(N,I,V) | | |<-|<-X<>X Accepted(N,I,W) | | | | | | | | | | | | !! Detect collision & recover | | X<>X<>X<>X Accepted(N+1,I,W) |<-----------X--X--X--X Response(W) | | | | | | Generalized PaxosGeneralized consensus explores the relationship between the operations of the replicated state machine and the consensus protocol that implements it [14]. The main discovery involves optimizations of Paxos when conflicting proposals could be applied in any order. i.e., when the proposed operations are commutative operations for the state machine. In such cases, the conflicting operations can both be accepted, avoiding the delays required for resolving conflicts and re-proposing the rejected operations. This concept is further generalized into ever-growing sequences of commutative operations, some of which are known to be stable (and thus may be executed). The protocol tracks these sequences ensuring that all proposed operations of one sequence are stabilized before allowing any operation non-commuting with them to become stable. ExampleIn order to illustrate Generalized Paxos, the example below shows a message flow between two concurrently executing clients and a replicated state machine implementing read/write operations over two distinct registers A and B.
Note that in this table indicates operations which are non-commutative. A possible sequence of operations : <1:Read(A), 2:Read(B), 3:Write(B), 4:Read(B), 5:Read(A), 6:Write(A)> Since <1:Read(A), 2:Read(B), 5:Read(A), 3:Write(B), 4:Read(B), 6:Write(A)> In practice, a commute occurs only when operations are proposed concurrently. Message flow: Generalized Paxos (example)Responses not shown. Note: message abbreviations differ from previous message flows due to specifics of the protocol, see [28] for a full discussion.Client Leader Acceptor Learner | | | | | | | | !! New Leader Begins Round | | X----->|->|->| | | Prepare(N) | | |<-----X- X- X | | Promise(N,null) | | X----->|->|->| | | Phase2Start(N,null) | | | | | | | | | | | | | | | | !! Concurrent commuting proposals | X------- ?|-----?|-?|-?| | | Propose(ReadA) X-----------?|-----?|-?|-?| | | Propose(ReadB) | | X------X-------------->|->| Accepted(N,<ReadA,ReadB>) | | |<--------X--X-------->|->| Accepted(N,<ReadB,ReadA>) | | | | | | | | | | | | | | | | !! No Conflict, both accepted | | | | | | | | Stable = <ReadA, ReadB> | | | | | | | | | | | | | | | | !! Concurrent conflicting proposals X-----------?|-----?|-?|-?| | | Propose(<WriteB,ReadA>) | X--------?|-----?|-?|-?| | | Propose(ReadB) | | | | | | | | | | X------X-------------->|->| Accepted(N,<WriteB,ReadA> . <ReadB>) | | |<--------X--X-------->|->| Accepted(N,<ReadB> . <WriteB,ReadA>) | | | | | | | | | | | | | | | | !! Conflict detected, leader chooses | | | | | | | | commutative order: | | | | | | | | V = <ReadA, WriteB, ReadB> | | | | | | | | | | X----->|->|->| | | Phase2Start(N+1,V) | | |<-----X- X- X-------->|->| Accepted(N+1,V) | | | | | | | | Stable = <ReadA, ReadB> . | | | | | | | | <ReadA, WriteB, ReadB> | | | | | | | | | | | | | | | | !! More conflicting proposals X-----------?|-----?|-?|-?| | | Propose(WriteA) | X--------?|-----?|-?|-?| | | Propose(ReadA) | | | | | | | | | | X------X-------------->|->| Accepted(N+1,<WriteA> . <ReadA>) | | |<--------X- X-------->|->| Accepted(N+1,<ReadA> . <WriteA>) | | | | | | | | | | | | | | | | !! Leader chooses order: | | | | | | | | W = <WriteA, ReadA> | | | | | | | | | | X----->|->|->| | | Phase2Start(N+2,W) | | |<-----X- X- X-------->|->| Accepted(N+2,W) | | | | | | | | Stable = <ReadA, ReadB> . | | | | | | | | <ReadA, WriteB, ReadB> . | | | | | | | | <WriteA, ReadA> | | | | | | | | PerformanceThe above message flow shows us that Generalized Paxos can leverage operation semantics to avoid collisions when the spontaneous ordering of the network fails. This allows the protocol to be in practice quicker than Fast Paxos. However, when a collision occurs, Generalized Paxos needs two additional round trips to recover. This situation is illustrated with operations WriteB and ReadB in the above schema. In the general case, such round trips are unavoidable and come from the fact that multiple commands can be accepted during a round. This makes the protocol more expensive than Paxos when conflicts are frequent. Hopefully two possible refinements of Generalized Paxos are possible to improve recovery time.[29]
Byzantine PaxosPaxos may also be extended to support arbitrary failures of the participants, including lying, fabrication of messages, collusion with other participants, selective non-participation, etc. These types of failures are called Byzantine failures, after the solution popularized by Lamport.[31] Byzantine Paxos[2] introduced by Castro and Liskov adds an extra message (Verify) which acts to distribute knowledge and verify the actions of the other processors: Message flow: Byzantine Multi-Paxos, steady stateClient Proposer Acceptor Learner | | | | | | | X-------->| | | | | | Request | X--------->|->|->| | | Accept!(N,I,V) | | X<>X<>X | | Verify(N,I,V) - BROADCAST | |<---------X--X--X------>|->| Accepted(N,V) |<---------------------------------X--X Response(V) | | | | | | | Fast Byzantine Paxos[3] introduced by Martin and Alvisi removes this extra delay, since the client sends commands directly to the Acceptors. Note the Accepted message in Fast Byzantine Paxos is sent to all Acceptors and all Learners, while Fast Paxos sends Accepted messages only to Learners): Message flow: Fast Byzantine Multi-Paxos, steady stateClient Acceptor Learner | | | | | | X----->|->|->| | | Accept!(N,I,V) | X<>X<>X------>|->| Accepted(N,I,V) - BROADCAST |<-------------------X--X Response(V) | | | | | | The failure scenario is the same for both protocols; Each Learner waits to receive F+1 identical messages from different Acceptors. If this does not occur, the Acceptors themselves will also be aware of it (since they exchanged each other's messages in the broadcast round), and correct Acceptors will re-broadcast the agreed value: Message flow: Fast Byzantine Multi-Paxos, failureClient Acceptor Learner | | | ! | | !! One Acceptor is faulty X----->|->|->! | | Accept!(N,I,V) | X<>X<>X------>|->| Accepted(N,I,{V,W}) - BROADCAST | | | ! | | !! Learners receive 2 different commands | | | ! | | !! Correct Acceptors notice error and choose | X<>X<>X------>|->| Accepted(N,I,V) - BROADCAST |<-------------------X--X Response(V) | | | ! | | Production use of Paxos{{sources|section|date=October 2018}}
See also
References1. ^{{Cite book|last=Lamport|first=Leslie|last2=Malkhi|first2=Dahlia|last3=Zhou|first3=Lidong|date=2009|title=Vertical Paxos and Primary-backup Replication|journal=Proceedings of the 28th ACM Symposium on Principles of Distributed Computing|series=PODC '09|location=New York, NY, USA|publisher=ACM|pages=312–313|doi=10.1145/1582716.1582783|isbn=9781605583969|citeseerx=10.1.1.150.1791}} [6][7][8][9][10][11][12][13][14][15][16][17][19][20][21][22][23][24]2. ^{{cite journal|last1=Castro|first1=Miguel|last2=Liskov|first2=Barbara|title=Practical Byzantine Fault Tolerance|journal=Proceedings of the Third Symposium on Operating Systems Design and Implementation|date=February 1999|pages=173–186|url=http://pmg.csail.mit.edu/papers/osdi99.pdf|accessdate=5 March 2018}} 3. ^{{cite journal|last1=Martin|first1=Jean-Philippe|last2=Alvisi|first2=Lorenzo|title=Fast Byzantine Consensus|journal=IEEE Transactions on Dependable and Secure Computing|date=July 2006|volume=3|issue=3|pages=202–215|doi=10.1109/TDSC.2006.35|url=https://www.cs.utexas.edu/~lorenzo/papers/fab.pdf|accessdate=5 March 2018}} 4. ^Aahlad et al.(2011). [https://www.wandisco.com/get?f=documentation%2Fwhitepapers%2FWANdisco_DConE_White_Paper.pdf “The Distributed Coordination Engine (DConE)”]. WANdisco white paper. 5. ^Kolbeck, Björn; Högqvist, Mikael; Stender, Jan; Hupfeld, Felix (2011). “Flease - Lease Coordination without a Lock Server”. 25th IEEE International Parallel & Distributed Processing Symposium (IPDPS 2011). 6. ^1 {{cite journal | last = Schneider | first = Fred | year = 1990 | title = Implementing Fault-Tolerant Services Using the State Machine Approach: A Tutorial | journal = ACM Computing Surveys | volume = 22 | issue = 4 | url = http://www.cs.cornell.edu/fbs/publications/smsurvey.pdf | format = | doi = 10.1145/98163.98167 | pages = 299–319 | citeseerx = 10.1.1.69.1536 }} 7. ^1 {{cite journal | last = Lamport | first = Leslie |date=July 1978 | title = Time, Clocks and the Ordering of Events in a Distributed System | journal = Communications of the ACM | volume = 21 | issue = 7 | pages = 558–565 | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#time-clocks | accessdate = 2007-02-02 | doi = 10.1145/359545.359563 }} 8. ^1 Leslie Lamport's history of the paper 9. ^1 {{cite journal | last = Lamport | first = Leslie |date=May 1998 | title = The Part-Time Parliament | journal = ACM Transactions on Computer Systems | volume = 16 | issue = 2 | pages = 133–169 | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#lamport-paxos | accessdate = 2007-02-02 | doi = 10.1145/279227.279229 }} 10. ^1 {{cite journal | title = Reconfiguring a State Machine | first1 = Leslie | last1 = Lamport | first2 = Dahlia | last2 = Malkhi | first3 = Lidong | last3 = Zhou | journal = SIGACT News | volume = 41 | number = 1 |date=March 2010 | pages = 63–73 | doi=10.1145/1753171.1753191 | citeseerx = 10.1.1.212.2168 }} 11. ^1 {{cite journal | title = Reliable Communication in the Presence of Failures | first1 = Kenneth | last1 = Birman | first2 = Thomas | last2 = Joseph | journal = ACM Transactions on Computer Systems |date=February 1987 | pages = 47–76 }} 12. ^1 {{cite journal | title = Consensus in the Presence of Partial Synchrony | url = http://groups.csail.mit.edu/tds/papers/Lynch/jacm88.pdf | first1 = Cynthia | last1 = Dwork | first2 = Nancy | last2 = Lynch | first3 = Larry | last3 = Stockmeyer | journal = Journal of the ACM | volume = 35 | number = 2 |date=April 1988 | pages = 288–323 | doi=10.1145/42282.42283 | citeseerx = 10.1.1.13.3423 }} 13. ^1 {{cite conference | last1 = Oki | first1 = Brian | last2 = Liskov | first2 = Barbara | year = 1988 | title = Viewstamped Replication: A New Primary Copy Method to Support Highly-Available Distributed Systems | booktitle = PODC '88: Proceedings of the seventh annual ACM Symposium on Principles of Distributed Computing | pages = 8–17 | url = http://portal.acm.org/citation.cfm?id=62549 | doi = 10.1145/62546.62549 }} 14. ^1 {{cite journal | last = Fischer | first = M. |date=April 1985 | title = Impossibility of distributed consensus with one faulty process | journal = Journal of the ACM | volume = 32 | issue = 2 | pages = 374–382 | doi = 10.1145/3149.214121 }} 15. ^1 2 3 4 5 {{cite conference | last1 = Lamport | first1 = Leslie | last2 = Massa | first2 = Mike | year = 2004 | title = Cheap Paxos | booktitle = Proceedings of the International Conference on Dependable Systems and Networks (DSN 2004) | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#web-dsn-submission }} 16. ^1 2 3 4 5 {{cite web | last = Lamport | first = Leslie | year = 2005 | title = Fast Paxos | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#fast-paxos }} 17. ^1 2 3 4 {{cite journal | last = Lamport | first = Leslie | year = 2005 | title = Generalized Consensus and Paxos | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#generalized }} 18. ^{{cite web | last = Castro | first = Miguel | year = 2001 | title = Practical Byzantine Fault Tolerance | url = http://citeseer.ist.psu.edu/castro01practical.html }} 19. ^1 {{cite web | last = Lamport | first = Leslie | year = 2004 | title = Lower Bounds for Asynchronous Consensus | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#lower-bound }} 20. ^1 {{cite book | last1 = Chandra | first1 = Tushar | last2 = Griesemer | first2 = Robert | last3 = Redstone | first3 = Joshua | year = 2007 | title = Paxos Made Live – An Engineering Perspective | journal = PODC '07: 26th ACM Symposium on Principles of Distributed Computing | pages = 398–407 | url = http://research.google.com/pubs/pub33002.html | doi = 10.1145/1281100.1281103 | isbn = 9781595936165 }} 21. ^1 Lamport, Leslie (2001). Paxos Made Simple ACM SIGACT News (Distributed Computing Column) 32, 4 (Whole Number 121, December 2001) 51-58. 22. ^1 {{cite journal | last1 = Lamport | first1 = Leslie | last2 = Shostak | first2 = Robert | last3 = Pease | first3 = Marshall |date=July 1982 | title = The Byzantine Generals Problem | journal = ACM Transactions on Programming Languages and Systems | volume = 4 | issue = 3 | pages = 382–401 | url = http://research.microsoft.com/users/lamport/pubs/pubs.html#byz | accessdate = 2007-02-02 | doi = 10.1145/357172.357176 | citeseerx = 10.1.1.64.2312 }} 23. ^1 {{cite conference | last1 = Pierre | first1 = Sutra | last2 = Marc | first2 = Shapiro | year = 2011 | title = Fast Genuine Generalized Consensus | booktitle = SRDS'11: 30th IEEE Symposium on Reliable Distributed Systems | url = http://pagesperso-systeme.lip6.fr/Marc.Shapiro/papers/FGGC-SRDS-2011.pdf }} 24. ^1 {{cite web | last = Turner | first = Bryan | year = 2007 | title = The Paxos Family of Consensus Protocols | url = http://www.fractalscape.org/2007/10/01/paxos-family.html }} }} External links
2 : Distributed algorithms|Fault-tolerant computer systems |
||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。