Distributed System (13)
Paxos
Concepts
- Proposal
- contains value and number
- Proposal number:
- An global unique “id” of the proposal
- Proposal value:
- the “content” of the proposal
3 types of roles:
- Proposer
- propose values to acceptors.
- Acceptors
- accept proposed values
- Learners
- learns the value that has been accepted by majority of acceptors.
- All processes.
When a value v is accpected by a majority (> 50%) acceptors, then that value v becomes the decided value.
Phase 1
Proposer
- sends
prepare
with a proposal nunmber n to a majority of acceptors. - reurest acceptors to:
- promise will not respond or accept to to any proposal with a lower number.
Acceptor
when recieving prepare
with number n:
- if it have not responded to a
prepare
with higher number- reply
OK
- if have accpeted other value v with lower number m < n
- attach v, m to the response
- reply
Phase 2
Proposer
- if recived
OK
from majority of acceptors- if applicable, set proposal value v = the v with highest proposal number m among respondes
- keep original v otherwise
- send
accept
with v, n
- if does not hear from majority of acceptors
- Wait for some time, and then issue a new request with higher
number
- Wait for some time, and then issue a new request with higher
Acceptor
When receives an accept
with number n:
- if have not responded a
prepare
with higher number- accept the proposal
Proof
At time , if a proposal is accepted by a majority of the acceptors, it means that all have not responded to a higher before acceptance.
Since any majority of the acceptors contains process that is in , no will be accepted before time . And after , is the highest proposal number and any majority will contain a acceptor in , so any proposal collecting a majority of OK
ends up having value .
Raft
Distributed System (13)
https://yzzzf.xyz/2024/04/02/distributed-system-13/