paxos made simple
DESCRIPTION
Paxos Made Simple. Leslie Lamport Summary: Piras Maha. Outline. History Problem Choosing A Value Learning Simple Example. History. Leslie Lamport Presented in 1990 Almost everyone dismissed it The first paper was a difficult read, hard to understand - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/1.jpg)
Paxos Made SimpleLeslie Lamport
Summary: Piras Maha
![Page 2: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/2.jpg)
OutlineHistoryProblemChoosing A ValueLearningSimple Example
![Page 3: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/3.jpg)
HistoryLeslie Lamport
Presented in 1990Almost everyone dismissed itThe first paper was a difficult read, hard to
understandTook 10 years before publication, required
almost a complete re-writeGained popularity really quickly in
distributed systemLots of decomposition and optimizations, still
being applied to date
![Page 4: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/4.jpg)
The ProblemAssume a collection of processesEach process proposes a valueConsidered consensus algorithm( chooses a
single value is chosen)If no value is proposed then no value should
be chosenIf a value has been chosen processes should
be able to learn chosen value
![Page 5: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/5.jpg)
The ProblemSafety requirement for consensus
Only a value proposed may be chosenOnly single value is chosenProcess never learns value has been chosen
unless it actually has beenThree roles of algorithm preformed by three
classes of agentsProposersAcceptorsLearners
![Page 6: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/6.jpg)
The ProblemAgents can communicate with each
asynchronously (through messaging)Agents operate at arbitrary speedMay fail, may restart (information should be
remembered)Messages may take arbitrary delivery times,
can be duplicated, can be lost but not corrupted
![Page 7: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/7.jpg)
Choosing A Value – Simple LogicA simple method: have one acceptor
A proposer sends a proposal to acceptorAcceptor chooses first value it receivesIssue: if acceptor fails, make further progress
not possible
![Page 8: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/8.jpg)
Choosing A Value – P1What if we used multiple acceptors?
Proposer sends value to a set of acceptorsAn acceptor may accept proposed valueValue chosen if majority (or large enough set of
acceptors) chooses itIn absence of message loss or failure, want a
value chosen even if only one value proposed by proposer
P1: An acceptor must accept the first proposal that it receives
![Page 9: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/9.jpg)
Choosing A Value – P1P1 raises an issue: several values proposed
by different proposers , where every accepted a value but no majority
Or two values were proposed and half were chosen by one set of acceptors
Failure of single acceptor could make it impossible to learn which value was chosen
![Page 10: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/10.jpg)
Choosing A Value – P1P1 and requirement considering value is
chosen when accepted by a majority imply acceptor must be allowed to accept multiple proposals
To track the proposals, each proposal consists of proposal number and value
Different proposal would have different numbers
A value is chosen when single proposal with that value is accepted by majority of acceptors
![Page 11: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/11.jpg)
Choosing A Value – P2Multiple proposals may be chosen but value
must be same in allP2: If a proposal with value v is chosen, then
every higher-number proposal that is chosen has value v
This guarantees that only single value will be chosen
Again, to be chosen, proposal must be accepted by at least one acceptor
P2a: If a proposal with a value v is chosen, then every higher-numbered proposal accepted by any acceptor has value v
![Page 12: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/12.jpg)
Choosing A ValueSince communication is asynchronous, a
proposal may be chosen with an acceptor c, not received any proposal
At this point if a new proposer issues a higher-number proposal with a different value, P1 requires c to accept, thereby violating P2a
P2b: IF a proposal with value v is chosen then every higher number proposal issued by any proposer has value v
![Page 13: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/13.jpg)
Choosing A ValueSince proposal must be issued before it is
accepted, P2b implies P2a which implies P2Prove P2
Assume proposal with number m and value v chosen
Any proposal issued with number n, n>m has value v
Using induction on n, can prove n had value v, with additional assumption: every proposal number with a number in the range m to (n-1) has value v
For proposal m to be chosen, a majority of acceptors C, where every acceptor in C has accepted it
![Page 14: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/14.jpg)
Choosing A ValueThis m (Hypothesis ) is chosen and it implies:
Every acceptor in C has accepted a proposal with number in the range m ...(n-1) and every proposal with a number in m...(n-1) accepted by any acceptor has value v
Since any set S, with majority acceptors, contains at least one C leads to proposal number n has value v by(leading to) :
P2c: For any v and n, if a proposal with value v and number n is issued, then there is a set S consisting of a majority of acceptors such that either (a) no acceptor in S has accepted any proposal number
less than n
![Page 15: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/15.jpg)
Choosing A Value – Issuing ProposalsOr (b) v is the value of the highest numbered proposal
among all proposals numbered less than n accepted by the acceptors in S
A proposer that wants to issue a proposal numbered n, must learn the highest numbered proposal with number less than n, if any, that has been accepted so far
To do this: a proposer chooses number n, sends request to acceptors asking for response containingPromise to not accept proposal numbered less than nProposal with highest number less than n, that has been
acceptedCalled: Prepare Request
![Page 16: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/16.jpg)
Choosing A Value – Issuing ProposalsIf proposer receives requested responses
from majority, then issue proposal with number n and value v (where v is highest numbered proposal among responses or new number if no proposals reported)
Proposer later sends a request that proposal has been accepted
![Page 17: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/17.jpg)
Choosing A Value - AcceptorAcceptor can receive two kinds of requests
from proposersPrepare requestAccept request
Can ignore requestsP1a: an acceptor can accept a proposal
number n if and only if it has not responded to a prepare request having a number greater than n
With this, a complete algorithm for choosing value
![Page 18: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/18.jpg)
Choosing A Value – Algorithm OptimizationConsider acceptor receives a prepare request
with number n, but already responded to prepare request with number greater than nTherefore promised not to accept any proposal
numbered nWhich means no reason to respond to this
request or respond to a request for a for a proposal that was already accepted
![Page 19: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/19.jpg)
Choosing A ValueNow, acceptor only needs to remember the
highest –number proposal that was accepted and the number of highest-numbered prepare request which was responded to
Since P2c kept invariant regardless of failures, acceptor must remember this information if failure or restart
Note: proposer can abandon proposal and forget all about it, as long as it doesn’t issue another proposal with same number
![Page 20: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/20.jpg)
Choosing A Value - AlgorithmPhase 1
Proposer sends prepare request with number n to majority of acceptors with proposal number n
If an acceptor receives a prepare request with number n (this n is greater than any prepare request which it has already responded up until now), then it responds to the request with a promise not to accept any more proposals numbered less than n and with the highest-numbered proposal (if any) that it has accepted
![Page 21: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/21.jpg)
Choosing A Value - AlgorithmPhase 2
If proposer receives response to its prepare request (for example numbered n) from majority of acceptors Proposer sends accept request to all acceptors with
proposal number n (with value v), where v is the value of the highest-numbered proposal from the responses OR is any value, if no responses were heard
If acceptor receives request for proposal number n, it will accept this proposal unless it already responded to a prepare with a number greater than n
![Page 22: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/22.jpg)
Choosing A ValueMultiple proposals can be made
Follows algorithm each timeProposer can abandon in the middle of
protocolCorrectness should be maintained
![Page 23: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/23.jpg)
Sequence with no errors
![Page 24: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/24.jpg)
Learning A Chosen ValueTo learn a value is chosen, learner must first
know the proposal has been accepted by majority
Obvious solution to let each acceptor respond to all learners (sending proposal)
Good: allows all learners find out about chosen value quickly
Bad: requires each acceptor to respond to each learner (large number of responses, number of learners x number of acceptors)
![Page 25: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/25.jpg)
Learning A Chosen ValueAnother option: have one distinguished
learnerHave this learner communicate to all other
learners (which value chosen)Bad: less reliable, if distinguished learner
failsRequires extra round for all learners to
discover chosen valueGood: requires less responses( number of
acceptors + number of learners)
![Page 26: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/26.jpg)
Learning A Chosen ValueNext approach would be to have a set of
distinguished learnersAcceptors send acceptances to the set of
distinguished learnersLarger the set, more reliable but adds
complexity/greater communication
![Page 27: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/27.jpg)
ProgressConsider: proposer p, completes phase 1, proposal
number n1Another proposer q, then completes phase 1 for
proposal number n2, n2>n1Proposer p’s accept request for n1 are ignored
since acceptors promised not to accept proposal number< n2
Then p, begins and completes phase 1 for n3, n3>n2
Therefore q’s phase 2 accept requests ignored, ...
![Page 28: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/28.jpg)
ProgressUse distinguished proposer, only one to try
issuing proposalsIf distinguished proposer communicates with
majority of acceptors, using proposal number greater than any already used, then it can succeed issuing an accepted proposal
Abandon proposal then trying again if it learns of new request with higher proposal number, this distinguished proposer will eventually choose high enough proposal number
![Page 29: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/29.jpg)
ProgressIf enough of proposers, acceptors and
communication network is working properly, electing single distinguished proposer can lead to liveness
Reliable algorithm for electing distinguished proposer may require randomness or real-time (based on research results)
![Page 30: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/30.jpg)
The ImplementationPaxos algorithm assumes network of processesIn its heart, considered consensus algorithm, with
agents playing proposer, acceptor, learnerLeader is chosen, plays distinguished proposer and
learnerPaxos consensus algorithm requests and responses
sent as ordinary messagesStable storage (alive during failure) contains
information acceptor must rememberAcceptor records in stable storage before sending
response
![Page 31: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/31.jpg)
State Machine ImplementationUse collection of servers, each one
implementing state machine independentlyDeterministicGuarantee execution osfsame sequence of state
machine commands
![Page 32: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/32.jpg)
Another LookTo put it simple terms: Paxos is used to have
consistency (ordering of semantics) on a platform with multiple machinesWhy is this important?
If ordering is jumbled, the meaning is lost Unreliable Could cause safety issues
![Page 33: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/33.jpg)
Another Look - ExampleJane has $0 in her accountJoe sends $100 to JaneWhen Jane is notified she received $100, she
sends $50 cheque to CRACRA cashs the cheque and spends it on
something useless
Without consistent ordering, each machine might view these in different order
![Page 34: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/34.jpg)
Author QAWhat would you like to convey to current and
future researchers and practitioners? Don’t pay attention to pedantic old farts like me telling you what to do.
What are the most important lessons you’ve learned in your career?
My career has been idiosyncratic. Any meaningful lessons I could draw from it would, at best, apply to people starting their careers 30 years ago.
Ref: http://research.microsoft.com/en-us/um/people/lamport/pubs/ds-interview.pdf
![Page 35: Paxos Made Simple](https://reader035.vdocuments.net/reader035/viewer/2022081421/56816759550346895ddc1a06/html5/thumbnails/35.jpg)
Referenceshttp://ayende.com/blog/4496/paxos-enlightme
nthttp://www.inf.usi.ch/faculty/pedone/MScThes
is/marco.pdfhttp://the-paper-trail.org/blog/?p=173Paxos Made Simple by Leslie Lamport (2001)