Mister Lamport’s paper Paxos Made Simple seems to be a really plain explanation of paxos algorithm,and….seriously…I DON’T THINK SO! Well when I started to doubt my life,I found someone asking such a question on Quora :
hahahahahahahhhhhh,I am not the only stupid man on the earth<( ̄︶ ̄)>
As we all know,consensus is the process of agreeing on one result among a group of participants and this problem becomes difficult when the participants or their communication medium may experience failures.Paxos is a family of protocols for solving consensus in a network of unreliable processors.The algorithm runs in a message-passing model with asynchrony and less than n/2 crash failures.
There are four roles in paxos algorithm:Client,Acceptor,Proposer,Learner.Paxos describes the actions of the processes by their roles in the protocol.In an typical implementation,a single processor may act as more than one role at the same time.The client issues a request to the distributed system.A Proposer advocates a client request, attempting to convince the Acceptors to agree on it, and acting as a coordinator to move the protocol forward when conflicts occur.Learners act as the replication factor for the protocol. Once a Client request has been agreed on by the Acceptors, the Learner may take action.The Acceptors act as the fault-tolerant “memory” of the protocol and play the role just like a decision maker.So proposers take the request from client to ask acceptor to make decision,acceptors make initial decision:accept or not accept.Then if the initial decision of acceptor is accept,proposer will ask acceptor once again to confirm the decision.And acceptor make final decision:final accept or final reject.The learner will learn from all the acceptors and if most of the acceptors accept the request,the learner will get the final result which it need.This is a typical vote-release process. The learner is the final executor of the request.
The problem that we are faced with:A collection of processes can propose values(i.e.A write request on a file in a distributed file server),a consensus algorithm ensures that a single one among the proposed values is chosen.There will be one and only one value that can be chosen.If no value is proposed by the processes,then no value should be chosen.If a value has been chosen,then processes should be able to learn the chosen value.
The safety requirements for consensus are:
(1) only one value that has been proposed can be chosen.
(2) only one single value is chosen,and
(3) a process never learns a value has been chosen unless it actually has been.
For each proposal,the algorithm proceeds as follws:
(1) The proposer sends a message prepare(n) to all acceptors.
(2) Each acceptor compares n to the highest-numbered proposal for which it has responded to a prepare message.If n is greater,it responds with ack(n,v,n_v) where v is the highest-numbered proposal it has accepted and n_v is the number of that proposal.
(3) The proposer waits to receive ack from a majority of acceptors.If any ack contained a value,it sets v to the most recent value that it received.It then sends accept(n,v) to all acceptors (or just a majority).
(4) Upon receiving accept(n,v),an acceptor accepts v unless it has already received prepare(n’) for some n’>n.If a majority of acceptors accept the value of a given proposal,that value becomes the decision value of the protocol.