Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal...

26
Paxos Algorithm Gurkan Solmaz COP 6938 - Cloud Computing - Fall 2012 Department of Electrical Engineering and Computer Science University of Central Florida - Orlando, FL Sept 19, 2012 1

Transcript of Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal...

Page 1: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Paxos Algorithm

Gurkan Solmaz

COP 6938 - Cloud Computing - Fall 2012

Department of Electrical Engineering and Computer Science University of Central Florida - Orlando, FL

Sept 19, 2012

1

Page 2: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Outline

Introduction & Brief History

The Problem

Requirements for Consensus

Basic Paxos Algorithm

Other Types of Paxos Algorithms

References

2

Page 3: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Introduction & History

Family of protocols for solving consensus

Published in 1989, by Leslie Lamport

Named after a fictional legislative consensus system

used on the Paxos island in Greece

Published as a journal article in 1998.

Obtained by application of the consensus to the state

machine approach 3

Page 4: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Introduction

Consensus: Reaching an agreement on one result among a

group of participants.

- Basis for the state machine approach to distributed

computing

State Machine Approach: Technique for converting an algorithm

into a fault-tolerant, distributed implementation

4

Page 5: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

The Problem

Assume a collection of processes that can propose values.

How to reach consensus/data consistency in distributed

system that can tolerate non-malicious failures?

5

Page 6: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Requirements for Consensus

Safety: − Only a value that has been proposed may be chosen − Only a single value is chosen − A process never learns that a value has been chosen

unless it actually has been

Liveness: − Some proposed value is eventually chosen − If a value has been chosen, a node can eventually learn

the value

6

Page 7: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Basic Paxos Algorithm

Roles of Agents:

− Client: Issues a request and waits for a response. − Proposer: Advocates a client request, tries to convince

Acceptors to agree on it, and acts as a coordinator to move the protocol forward when conflicts occur.

− Acceptor: Acts as the fault-tolerant "memory" of the protocol, collected into groups called Quorums.

− Learner: Acts as the replication factor for the protocol. Once request has been agreed, the Learner may take action

− Leader: A distinguished Proposer (called the leader) to make progress.

7

Page 8: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Basic Paxos Algorithm Phase 1 (prepare): - A proposer selects a proposal number n and sends a prepare

request with number n to majority of acceptors. - If an acceptor receives a prepare request with number n greater

than that of any prepare request it saw, it responses YES to that request with a promise not to accept any more proposals numbered less than n and include the highest-numbered proposal (if any) that it has accepted.

8

Page 9: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Basic Paxos Algorithm Phase 2 (accept): - If the proposer receives a response YES to its prepare requests

from a majority of acceptors, then it sends an accept request to each of those acceptors for a proposal numbered n with a values v which is the value of the highest-numbered proposal among the responses.

- If an acceptor receives an accept request for a proposal

numbered n, it accepts the proposal unless it has already responded to a prepare request having a number greater than n.

9

Page 10: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Basic Paxos Algorithm

Definition of a chosen - A value is chosen at proposal number n if and only if majority of

acceptors accept that value in phase 2 of the proposal number.

Properties

- P1: Any proposal number is unique. - P2: Any two set of acceptors have at least one acceptor in

common. - P3: The value sent out in phase 2 is the value of the

highest numbered proposal of all the responses in phase 1

10

Page 11: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Basic Paxos Algorithm Typical Deployment - Each participating process acts in three roles; Proposer,

Acceptor and Learner - 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

- By merging roles, the protocol "collapses" into an efficient client-

master-replica style deployment 11

Page 12: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Paxos Algorithm - Examples Message Flow: First round is successful

12

Page 13: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Paxos Algorithm - Examples Message Flow: Basic Paxos, failure of Acceptor

13

Page 14: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Paxos Algorithm - Examples Message Flow: Basic Paxos, failure of Proposer (re-election not shown, one instance, two rounds)

14

Page 15: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Other Types of Paxos Algorithms Multi-Paxos Cheap Paxos Fast Paxos Generalized Paxos Byzantine Paxos

15

Page 16: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Multi-Paxos Reduces the significant amount of overhead If the leader is stable, phase 1 is unnecessary for future instances

with the same leader To achieve this, instance number “I” is included along with each

value. Reduces the failure-free message delay (proposal to learning)

from 4 delays to 2 delays

16

Page 17: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

17

Page 18: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

18

Page 19: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Cheap Paxos Extends Basic Paxos to tolerate F failures with F+1 main

processors and F auxiliary processors by dynamically reconfiguring after each failure

19

Page 20: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Fast Paxos Fast Paxos allows 2 message delays, but requires 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. 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).

20

Page 21: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

21 21

Page 22: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Generalized Paxos Involves optimizations of the consensus protocol when conflicting

proposals could be applied to the state machine in any order. The operations proposed by the conflicting proposals are

commutative operations

22

Page 23: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Byzantine Paxos Extension to support arbitrary failures of the participants,

including lying, fabrication of messages, collusion with other participants, selective non-participation, etc.

Adds an extra message (Verify) which acts to distribute knowledge and verify the actions of the other processors

23

Page 24: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

Fast Byzantine Paxos

24

Page 25: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

References Dan C. Marinescu “Cloud Computing: Theory and Practice” Leslie Lamport (2001) “Paxos made simple.” Leslie Lamport (2005). "Fast Paxos" Leslie Lamport (2005). "Cheap Paxos” Leslie Lamport (2005). “Generalized Consensus and Paxos.” “Wikipedia,” http://en.wikipedia.org/wiki/Paxos_(computer_science). Tran Nguyen, A talk on Paxos, http://www.cs.nyu.edu/srg/.

25

Page 26: Paxos Algorithmdcm/Teaching/COP6938-Cloud...Definition of a chosen - A value is chosen at proposal number n if and only if majority of acceptors accept that value in phase 2 of the

26

Thank you !