distributed systems total order broadcast · 2018. 10. 19. · distributed systems total order...

26
Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory

Upload: others

Post on 13-Oct-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Distributed systems

Total Order Broadcast

Prof R. GuerraouiDistributed Programming Laboratory

Page 2: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

OverviewIntuitions: what is total order broadcast?

Specifications of total order broadcast

Consensus-based total order algorithm

Page 3: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Broadcast

B

A

C

m

m

deliver

broadcast

deliver

Page 4: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Intuitions (1)In reliable broadcast, the processes are free to deliver messages in any order they wishIn causal broadcast, the processes need to

deliver messages according to some order (causal order) The order imposed by causal broadcast is however partial: some messages might be delivered in different order by the processes

Page 5: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Reliable Broadcast

p1

p2

p3

m2

m1

m1

m2

m1

m3

m1 m2 m3

m3

m3

m2

Page 6: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Causal Broadcast

p1

p2

p3

m2

m1

m1

m2

m1

m3

m1 m2 m3

m3

m3

m2

Page 7: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Intuitions (2)In total order broadcast, the processes must deliver all messages according to the same order (i.e., the order is now total)Note that this order does not need to respect causality (or even FIFO ordering) Total order broadcast can be made to respect causal (or FIFO) ordering

Page 8: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Total Order Broadcast (I)

p1

p2

p3

m2

m1

m3

m2

m1

m3

m1m2 m3

m1

m3

m2

Page 9: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Total Order Broadcast (II)

p1

p2

p3

m1

m2

m3

m1

m1

m3

m2m1 m3

m2

m3

m2

Page 10: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Intuitions (3)A replicated service where the replicas need to treat the requests in the same order to preserve consistency

(we talk about state machine replication)

A notification service where the subscribers need to get notifications in the same order

Page 11: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Modules of a process

request

indication

indication

indication

request

Page 12: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

OverviewIntuitions: what is total order broadcast?

Specifications of total order broadcast

Consensus-based algorithm

Page 13: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Total order broadcast (tob)Events

Request: <toBroadcast, m>Indication: <toDeliver, src, m>

• Properties:• RB1, RB2, RB3, RB4• Total order property

Page 14: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Specification (I)

Validity: If pi and pj are correct, then every message broadcast by pi is eventually delivered by pj

No duplication: No message is delivered more than once

No creation: No message is delivered unless it was broadcast

(Uniform) Agreement: For any message m. If a correct (any) process delivers m, then every correct process delivers m

Page 15: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Specification (II)(Uniform) Total order:

Let m and m’ be any two messages. Let pi be any (correct) process that delivers m without having delivered m’ Then no (correct) process delivers m’ before m

Page 16: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Specifications

Note the difference with the following properties:

Let pi and pj be any two correct (any) processes that deliver two messages m and m’. If pi delivers m’ before m, then pj delivers m’ before m.

Let pi and pj be any two (correct) processes that deliver a message m. If pi delivers a message m’ before m, then pj delivers m’ before m.

Page 17: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

p1

p2

p3

m1

m2p4

crash

crashm2

m1

Page 18: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

p1

p2

p3

m1

m2p4

crash

crashm2

m1

Page 19: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

OverviewIntuitions: what total order broadcast can bring?

Specifications of total order broadcast

Consensus-based algorithm

Page 20: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

(Uniform) ConsensusIn the (uniform) consensus problem, the processes propose values and need to agree on one among these values

C1. Validity: Any value decided is a value proposed C2. (Uniform) Agreement: No two correct (any)

processes decide differently C3. Termination: Every correct process eventually

decidesC4. Integrity: Every process decides at most once

Page 21: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

ConsensusEvents

Request: <Propose, v>Indication: <Decide, v’>

• Properties:• C1, C2, C3, C4

Page 22: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Modules of a process

request

indication

indication

indication

requestindicationrequest

Page 23: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

AlgorithmImplements: TotalOrder (to).Uses:

ReliableBroadcast (rb). Consensus (cons);

upon event < Init > dounordered: = delivered: = Æ;wait := false;sn := 1;

Page 24: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Algorithm (cont’d)upon event < toBroadcast, m> do

trigger < rbBroadcast, m>;upon event <rbDeliver,sm,m> and (m Ï delivered) do

unordered := unordered U {(sm,m)};

upon (unordered ¹ Æ) and not(wait) dowait := true:trigger < Propose, unordered>sn;

Page 25: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Algorithm (cont’d)upon event <Decide,decided>sn do

unordered := unordered \ decided;ordered := deterministicSort(decided);for all (sm,m) in ordered:

trigger < toDeliver,sm,m>;delivered := delivered U {m};

sn : = sn + 1;wait := false;

Page 26: Distributed systems Total Order Broadcast · 2018. 10. 19. · Distributed systems Total Order Broadcast Prof R. Guerraoui Distributed Programming Laboratory. Overview Intuitions:what

Equivalences1. One can build consensus with total order

broadcast2. One can build total order broadcast with

consensus and reliable broadcast

Therefore, consensus and total order broadcast are equivalent problems in a system with reliable channels