Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in...
Transcript of Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in...
![Page 1: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/1.jpg)
Paxos Made Simple
Lamport
Thomas Marshall
![Page 2: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/2.jpg)
Motivation
● We need a way to maintain consistency in a distributed system in the presence of failures.
● 2PC works, but can get “stuck”, so a consensus algorithm is better.
![Page 3: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/3.jpg)
Background
● Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures.
● Dale Skeen proposes 3PC in the 1980s, but it produces incorrect results in some situations.
● Leslie Lamport proposes Paxos in 1998; the original paper describes the ancient Greek civilization on the Paxos island.
![Page 4: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/4.jpg)
Example
● Leader election (eg. Mesos and Zookeeper) – important to only have one leader at a time.
● Some node(s) propose to be leader, other nodes can accept or reject.
![Page 5: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/5.jpg)
Paxos
● We want to choose a value and have every node in the cluster agree on the value.
● Three classes of agents: proposers, acceptors, learners.
● Failures are possible, but non-Byzantine.
![Page 6: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/6.jpg)
Safety Properties
● Only a value that has been proposed may be accepted.
● Only a single value is chosen.
● An agent never learns that a value has been chosen unless it actually has been.
![Page 7: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/7.jpg)
Algorithm
● A proposer selects a proposal number n and sends a request to the acceptors.
● If an acceptor has not already accepted a proposal with number greater than n, it responds that it can accept this proposal.
![Page 8: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/8.jpg)
Algorithm (cont)
● If a proposer receives ready responses from a majority of acceptors, it sends an accept message.
● An acceptor that receives an accept message accepts the proposal unless it has responded to a prepare with a number greater than n.
![Page 9: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/9.jpg)
Paxos Example
proposer
acceptors
prepare = 8
prepare = 8
prepare = 8
![Page 10: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/10.jpg)
Paxos Example
proposer
acceptors
ready
ready
ready
highest proposed = 8
highest proposed = 8
highest proposed = 8
![Page 11: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/11.jpg)
Paxos Example
proposer
acceptors
accept = (8, foo)
accept = (8, foo)
accept = (8, foo)
highest proposed = 8
highest proposed = 8
highest proposed = 8
![Page 12: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/12.jpg)
Paxos Example
proposer
acceptors
accepted = (8. foo)
highest accepted = (8, foo)
highest accepted = (8, foo)
highest accepted = (8, foo)
accepted = (8. foo)
accepted = (8. foo)
![Page 13: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/13.jpg)
Paxos Example
proposer
leaners
success = (8, foo)
success = (8, foo)
success = (8, foo)
![Page 14: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/14.jpg)
Paxos Example (2)
proposers
acceptors
prepare = (8, A)
A
B
prepare = (8, A)
prepare = (8, A)
![Page 15: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/15.jpg)
proposers
acceptors
ready
A
B
ready
ready
highest proposed = (8, A)
highest proposed = (8, A)
highest proposed = (8, A)
Paxos Example (2)
![Page 16: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/16.jpg)
acceptors
prepare = (9, B)A
B
highest proposed = (8, A)
highest proposed = (8, A)
highest proposed = (8, A)
prepare = (9, B)
prepare = (9, B)
Paxos Example (2)
![Page 17: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/17.jpg)
proposers
acceptors
A
B
highest proposed = (8, A)
highest proposed = (9, B)
highest proposed = (9, B)
ready
ready
Paxos Example (2)
![Page 18: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/18.jpg)
proposers
acceptors
accept = ((8, A), foo)
A
B
highest proposed = (8, A)
highest proposed = (9, B)
highest proposed = (9, B)
accept = ((8, A), foo)
accept = ((8, A), foo)
Paxos Example (2)
![Page 19: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/19.jpg)
proposers
acceptors
accepted = ((8, A), foo)
A
B
highest accepted = ((8, A), foo)
highest proposed = (9, B)
highest proposed = (9, B)
Paxos Example (2)
![Page 20: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/20.jpg)
proposers
acceptors
accept = ((9, B), bar)
A
B
highest accepted = ((8, A), foo)
highest proposed = (9, B)
highest proposed = (9, B)
accept = ((9, B), bar)
accept = ((9, B), bar)
Paxos Example (2)
![Page 21: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/21.jpg)
proposers
acceptors
A
B
highest accepted = ((8, A), foo)
highest accepted = ((9, B), bar)
highest accepted = ((9, B), bar)
accepted = ((9, B), bar)
accepted = ((9, B), bar)
Paxos Example (2)
![Page 22: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/22.jpg)
proposers
acceptors
prepare = (10, A)
A
B
prepare = (10, A)
prepare = (10, A)
highest accepted = ((8, A), foo)
highest accepted = ((9, B), bar)
highest accepted = ((9, B), bar)
Paxos Example (2)
![Page 23: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/23.jpg)
proposers
acceptors
A
B
highest accepted = ((8, A), foo)highest proposed = (10, A)
highest accepted = ((9, B), bar)highest proposed = (10, A)
highest accepted = ((9, B), bar)highest proposed = (10, A)
ready = ((10, A), ((9, B), bar)
ready = ((10, A), ((9, B), bar)
ready = ((10, A), ((8, A), foo)
Paxos Example (2)
![Page 24: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/24.jpg)
proposers
acceptors
A
B
highest accepted = ((8, A), foo)highest proposed = (10, A)
highest accepted = ((9, B), bar)highest proposed = (10, A)
highest accepted = ((9, B), bar)highest proposed = (10, A)
accept = ((10, A), bar)
accept = ((10, A), bar)
accept = ((10, A), bar)
Paxos Example (2)
![Page 25: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/25.jpg)
proposers
acceptors
A
B
highest accepted = ((10, A), bar)
highest accepted = ((10, A), bar)
highest accepted = ((10, A), bar)
accepted = ((10, A), bar)
accepted = ((10, A), bar)
accepted = ((10, A), bar)
Paxos Example (2)
![Page 26: Paxos Made Simple Lamportpavlo/courses/fall2013/static/... · Background Jim Gray proposes 2PC in the 1970s, but it blocks on single node failures. Dale Skeen proposes 3PC in the](https://reader033.fdocuments.us/reader033/viewer/2022042920/5f67918105498e44032ea416/html5/thumbnails/26.jpg)
Progress
● You can imagine “dueling” proposers that continually propose higher and higher proposal numbers without any ever being accepted.
● Solution: distinguished proposer.