Avoiding Coordination Announcements O ffi ce Hours No office hours - - PowerPoint PPT Presentation

β–Ά
avoiding coordination announcements o ffi ce hours
SMART_READER_LITE
LIVE PREVIEW

Avoiding Coordination Announcements O ffi ce Hours No office hours - - PowerPoint PPT Presentation

Avoiding Coordination Announcements O ffi ce Hours No office hours on 11/15: I am not here. O ffi ce Hours No office hours on 11/15: I am not here. No office hours on 11/22: Everyone should be out having and . O ffi ce Hours


slide-1
SLIDE 1

Avoiding Coordination

slide-2
SLIDE 2

Announcements

slide-3
SLIDE 3

Office Hours

  • No office hours on 11/15: I am not here.
slide-4
SLIDE 4

Office Hours

  • No office hours on 11/15: I am not here.
  • No office hours on 11/22: Everyone should be out having πŸ₯¨ and πŸ¦„.
slide-5
SLIDE 5

Office Hours

  • No office hours on 11/15: I am not here.
  • No office hours on 11/22: Everyone should be out having πŸ₯¨ and πŸ¦„.
  • No office hours on 11/29: I am not here.
slide-6
SLIDE 6

Office Hours

  • No office hours on 11/15: I am not here.
  • No office hours on 11/22: Everyone should be out having πŸ₯¨ and πŸ¦„.
  • No office hours on 11/29: I am not here.
  • E-mail me if you want to meet/need help.
slide-7
SLIDE 7

Office Hours

  • No office hours on 11/15: I am not here.
  • No office hours on 11/22: Everyone should be out having πŸ₯¨ and πŸ¦„.
  • No office hours on 11/29: I am not here.
  • E-mail me if you want to meet/need help.
  • Probably going to be over Skype or some such medium.
slide-8
SLIDE 8

Office Hours

  • No office hours on 11/15: I am not here.
  • No office hours on 11/22: Everyone should be out having πŸ₯¨ and πŸ¦„.
  • No office hours on 11/29: I am not here.
  • E-mail me if you want to meet/need help.
  • Probably going to be over Skype or some such medium.
  • Or in person on 11/26 or 11/27.
slide-9
SLIDE 9

Final Project

slide-10
SLIDE 10

Final Project

  • Hopefully everyone has started...
slide-11
SLIDE 11

Final Project

  • Hopefully everyone has started...
  • ... at least thinking about the project.
slide-12
SLIDE 12

Final Project

  • Hopefully everyone has started...
  • ... at least thinking about the project.
  • Remember: no extensions or late days -- must receive final report on Dec 12.
slide-13
SLIDE 13

Onto Science...

slide-14
SLIDE 14

So Far...

  • Looked at mechanisms to achieve consensus, get machines to work together.
slide-15
SLIDE 15

So Far...

  • Looked at mechanisms to achieve consensus, get machines to work together.
  • A few different algorithms, a few different failure conditions.
slide-16
SLIDE 16

So Far...

  • Looked at mechanisms to achieve consensus, get machines to work together.
  • A few different algorithms, a few different failure conditions.
  • Powerful primitive: can replicate any deterministic state machine.
slide-17
SLIDE 17

So Far...

  • Looked at mechanisms to achieve consensus, get machines to work together.
  • A few different algorithms, a few different failure conditions.
  • Powerful primitive: can replicate any deterministic state machine.
  • Don't even need to implement or understand consensus to do this.
slide-18
SLIDE 18

So Far...

  • Looked at mechanisms to achieve consensus, get machines to work together.
  • A few different algorithms, a few different failure conditions.
  • Powerful primitive: can replicate any deterministic state machine.
  • Don't even need to implement or understand consensus to do this.
  • Powerful abstraction: replicate most programs, get fault tolerance.
slide-19
SLIDE 19

So Far...

slide-20
SLIDE 20

So Far...

  • But everything is not rosy:
slide-21
SLIDE 21

So Far...

  • But everything is not rosy:
  • Configure and initialize system for correctness.
slide-22
SLIDE 22

So Far...

  • But everything is not rosy:
  • Configure and initialize system for correctness.
  • Need to communicate and wait before responding to any request.
slide-23
SLIDE 23

So Far...

  • But everything is not rosy:
  • Configure and initialize system for correctness.
  • Need to communicate and wait before responding to any request.
  • Can we do better?
slide-24
SLIDE 24

Yesβ€½

slide-25
SLIDE 25

Self Stabilizing Algorithms

slide-26
SLIDE 26

Setting

  • Treat program as transition machine.
slide-27
SLIDE 27

Setting

  • Treat program as transition machine.
  • Where some states are good.
slide-28
SLIDE 28

Setting

  • Treat program as transition machine.
  • Where some states are good.
  • All transitions from good states go to good.
slide-29
SLIDE 29

Setting

  • Treat program as transition machine.
  • Where some states are good.
  • All transitions from good states go to good.
  • Self-stabilization:
  • From any state arrive at good state.
  • In bounded steps.
slide-30
SLIDE 30

Setting

  • Treat program as transition machine.
  • Where some states are good.
  • All transitions from good states go to good.
  • Self-stabilization:
  • From any state arrive at good state.
  • In bounded steps.
slide-31
SLIDE 31

Djikstra's Example

  • Mutual exclusion: only one process gets to write (or compute) at a time.

1 2 3 4

x0 x1 x2 x3 x4

slide-32
SLIDE 32

Djikstra's Example

  • Mutual exclusion: only one process gets to write (or compute) at a time.

1 2 3 4

x0 x1 x2 x3 x4

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-33
SLIDE 33

Djikstra's Example

  • When and why can this provide mutual exclusion?

1 2 3 4

x0 x1 x2 x3 x4

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-34
SLIDE 34

Djikstra's Example

1 2 3 4

x0=1 x1=1 x2=1 x3=1 x4=1

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-35
SLIDE 35

Djikstra's Example

1 2 3 4

x0=2 x1=1 x2=1 x3=1 x4=1

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-36
SLIDE 36

Djikstra's Example

1 2 3 4

x0=2 x1=2 x2=1 x3=1 x4=1

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-37
SLIDE 37

Djikstra's Example

1 2 3 4

x0=2 x1=2 x2=2 x3=1 x4=1

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-38
SLIDE 38

Djikstra's Example

1 2 3 4

x0=2 x1=2 x2=2 x3=2 x4=2

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-39
SLIDE 39

Djikstra's Example

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

What happens with random initial values?

slide-40
SLIDE 40

Djikstra's Example

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-41
SLIDE 41

Djikstra's Example

  • Assuming a fair execution.

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-42
SLIDE 42

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-43
SLIDE 43

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Round here is every processor got a chance to run.

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-44
SLIDE 44

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Round here is every processor got a chance to run.
  • Why?

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-45
SLIDE 45

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Lemma 2: There is some value c in 0..(n+1) s.t. xi β‰  c βˆ€i

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-46
SLIDE 46

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Lemma 2: There is some value c in 0..(n+1) s.t. xi β‰  c βˆ€i
  • Why?

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-47
SLIDE 47

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Lemma 2: There is some value c in 0..(n+1) s.t. xi β‰  c βˆ€i

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-48
SLIDE 48

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Lemma 2: There is some value c in 0..(n+1) s.t. xi β‰  c βˆ€i
  • Theorem: Get to all xis being equal in O(n2) rounds.

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-49
SLIDE 49

Djikstra's Example

  • Assuming a fair execution.
  • Lemma 1: At least every n rounds x0 changes its value.
  • Lemma 2: There is some value c in 0..(n+1) s.t. xi β‰  c βˆ€i
  • Theorem: Get to all xis being equal in O(n2) rounds.
  • Why?

1 2 3 4

x0=1 x1=2 x2=3 x3=4 x4=0

At process 0 do { if (x4 == x0) { x0 = (x0 + 1) % 5; } } while (true); At process n do { if (xn != xn-1) { xn = xn-1; } } while (true);

slide-50
SLIDE 50

Other Self Stabilizing Algorithms?

slide-51
SLIDE 51

Finding a Minimal Spanning Tree

slide-52
SLIDE 52

Finding a Minimal Spanning Tree

slide-53
SLIDE 53

Finding a Minimal Spanning Tree

slide-54
SLIDE 54

Thoughts on how?

slide-55
SLIDE 55

d=0

At root do { for n in nbr { send(n, <d=0, parent=false>) } } } while (true); At process n do { n[i], parent = recv(nbr i) d = min(n) parent = find(i s.t. n[i] = d-1) send(parent, <d=d, parent=true>) for n in nbr { if n!= parent { send(n, <d = d, parent=false>) } } } while (true);

Finding a Minimal Spanning Tree

slide-56
SLIDE 56

d=0

Why does this work?

d=8 d=100

Finding a Minimal Spanning Tree

d=22

slide-57
SLIDE 57

d=0

Why does this work?

d=8 d=100

Finding a Minimal Spanning Tree

d=22 d=1 d=1 d=23

slide-58
SLIDE 58

d=0

Why does this work?

d=8 d=100

Finding a Minimal Spanning Tree

d=22 d=1 d=1 d=23 d=2

slide-59
SLIDE 59

d=0

Why does this work?

d=100

Finding a Minimal Spanning Tree

d=22 d=1 d=1 d=23 d=2 d=2

slide-60
SLIDE 60

d=0

Why does this work?

d=100

Finding a Minimal Spanning Tree

d=1 d=1 d=23 d=2 d=2 d=2

slide-61
SLIDE 61

d=0

Why does this work?

Finding a Minimal Spanning Tree

d=1 d=1 d=23 d=2 d=2 d=2 d=3

slide-62
SLIDE 62

Maximal Matching

slide-63
SLIDE 63

Maximal Matching

slide-64
SLIDE 64

Maximal Matching

slide-65
SLIDE 65

How?

slide-66
SLIDE 66

partner = null do { broadcast(id, partner) collect partners for id if partner = null and exists j s.t. partners[j]=id { partner = j } if partner = null and exists j s.t. partners[j] = null { partner = j } if partner = j and partners[j] != id { partner = null } } while (true);

slide-67
SLIDE 67

Why?

slide-68
SLIDE 68

CRDTs

slide-69
SLIDE 69

Revisiting RSMs

Application Application Application Application Ordering Ordering Ordering Ordering

slide-70
SLIDE 70

Revisiting RSMs

Application Application Application Application Ordering Ordering Ordering Ordering

Client Client Client Client

slide-71
SLIDE 71

Revisiting RSMs

Application Application Application Application Ordering Ordering Ordering Ordering

Client Client Client Client

slide-72
SLIDE 72

Revisiting RSMs

Application Application Application Application Ordering Ordering Ordering Ordering

Client Client Client Client

slide-73
SLIDE 73

What if we didn't care about ordering

Application Application Application Application Gossip Gossip Gossip Gossip

slide-74
SLIDE 74

What if we didn't care about ordering

Application Application Application Application Gossip Gossip Gossip Gossip

Client Client Client Client

slide-75
SLIDE 75

What if we didn't care about ordering

Application Application Application Application Gossip Gossip Gossip Gossip

Client Client Client Client

slide-76
SLIDE 76

What if we didn't care about ordering

Application Application Application Application Gossip Gossip Gossip Gossip

Client Client Client Client

slide-77
SLIDE 77

Challenge: Ensuring correctness despite reordering

slide-78
SLIDE 78

Challenge

Peer 0 Peer 1 Peer 2 Peer 3 X Y Z A

slide-79
SLIDE 79

Challenge

Peer 0 Peer 1 Peer 2 Peer 3 X Y Z A merge(X, Y) merge(Z, X) merge(Y, Z) merge(X, A)

slide-80
SLIDE 80

Challenge

Peer 0 Peer 1 Peer 2 Peer 3 X Y Z A merge(X, Y) merge(Z, X) merge(Y, Z) merge(X, A) m(Y,m(Z, X)) m(A,m(X, Y)) m(X,m(Y, Z)) m(Y,m(X, A))

slide-81
SLIDE 81

Challenge

Peer 0 Peer 1 Peer 2 Peer 3 X Y Z A merge(X, Y) merge(Z, X) merge(Y, Z) merge(X, A) m(Y,m(Z, X)) m(A,m(X, Y)) m(X,m(Y, Z)) m(Y,m(X, A)) m(A, m(Y,m(Z, X))) m(Z, m(A,m(X, Y))) m(A, m(X,m(Y, Z))) m(Z, m(Y, m(X, A)))

slide-82
SLIDE 82

Challenge

Peer 0 Peer 1 Peer 2 Peer 3 X Y Z A merge(X, Y) merge(Z, X) merge(Y, Z) merge(X, A) m(Y,m(Z, X)) m(A,m(X, Y)) m(X,m(Y, Z)) m(Y,m(X, A)) m(A, m(Y,m(Z, X))) m(Z, m(A,m(X, Y))) m(A, m(X,m(Y, Z))) m(Z, m(Y, m(X, A))) Need all of these to be equal.

slide-83
SLIDE 83

Modelling a Merge Function

slide-84
SLIDE 84

Modelling a Merge Function

  • Treat updates as a set.
slide-85
SLIDE 85

Modelling a Merge Function

  • Treat updates as a set.
  • For previous example {A, X, Y, Z}
slide-86
SLIDE 86

Modelling a Merge Function

  • Treat updates as a set.
  • For previous example {A, X, Y, Z}
  • Define merge function to be the least upper bound (similar to supremum).
slide-87
SLIDE 87

Modelling a Merge Function

  • Treat updates as a set.
  • For previous example {A, X, Y, Z}
  • Define merge function to be the least upper bound (similar to supremum).
  • Commutative, associative and idempotent.
slide-88
SLIDE 88

Modelling a Merge Function

  • Treat updates as a set.
  • For previous example {A, X, Y, Z}
  • Define merge function to be the least upper bound (similar to supremum).
  • Commutative, associative and idempotent.
  • Thus LUB(A, LUB(X, LUB(Y, Z)))) = LUB(X, LUB(A, LUB(Y, Z)))) = ...
slide-89
SLIDE 89

Modelling a Merge Function

  • Treat updates as a set.
  • For previous example {A, X, Y, Z}
  • Define merge function to be the least upper bound (similar to supremum).
  • Commutative, associative and idempotent.
  • Thus LUB(A, LUB(X, LUB(Y, Z)))) = LUB(X, LUB(A, LUB(Y, Z)))) = ...
  • In abstract algebra posets with LUBs are called semilattices.
slide-90
SLIDE 90

Is this enough?

slide-91
SLIDE 91

Modelling a Merge Function

slide-92
SLIDE 92

Modelling a Merge Function

  • Sufficient for consistency.
slide-93
SLIDE 93

Modelling a Merge Function

  • Sufficient for consistency.
  • Not sufficient to make sure all semantics are preserved.
slide-94
SLIDE 94

Modelling a Merge Function

  • Sufficient for consistency.
  • Not sufficient to make sure all semantics are preserved.
  • In particular picking the least upper bound might loose operations.
slide-95
SLIDE 95

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] x = [0, 0, 0] x = [0, 0, 0] Is element wise max a LUB?

slide-96
SLIDE 96

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] x = [0, 0, 0] x = [0, 0, 0] + Is element wise max a LUB?

slide-97
SLIDE 97

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] x = [0, 0, 0] + x = [1, 0, 0] Is element wise max a LUB?

slide-98
SLIDE 98

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] x = [0, 0, 0] +

  • x = [1, 0, 0]

Is element wise max a LUB?

slide-99
SLIDE 99

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] +

  • x = [1, 0, 0]

x = [0, 0, -1] Is element wise max a LUB?

slide-100
SLIDE 100

Counters

Peer 0 Peer 1 Peer 3 x = [0, 0, 0] +

  • x = [1, 0, 0]

x = [0, 0, -1] Suppose we use element wise max as LUB. Is element wise max a LUB?

slide-101
SLIDE 101

Counters

Peer 0 Peer 1 Peer 3 +

  • Suppose we use element wise max as LUB.

Is element wise max a LUB? x = LUB([1, 0, 0], [0,0,0], [0,0, -1]) x = LUB([1, 0, 0], [0,0,0], [0,0, -1]) x = LUB([1, 0, 0], [0,0,0], [0,0, -1])

slide-102
SLIDE 102

Counters

Peer 0 Peer 1 Peer 3 +

  • Suppose we use element wise max as LUB.

Is element wise max a LUB? x = [1, 0, 0] x = [1, 0, 0] x = [1, 0, 0]

slide-103
SLIDE 103

Modelling a Merge Function

  • Need it to be a least upper bound for the state which is a semilattice.
slide-104
SLIDE 104

Modelling a Merge Function

  • Need it to be a least upper bound for the state which is a semilattice.
  • Need LUB to be monotonic.
slide-105
SLIDE 105

Modelling a Merge Function

  • Need it to be a least upper bound for the state which is a semilattice.
  • Need LUB to be monotonic.
  • Each application preserves more information.
slide-106
SLIDE 106

Build a Collaborative Editor using CRDTs

slide-107
SLIDE 107

It was the best of times, it was the poohest of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of credulity, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness

slide-108
SLIDE 108

It was the best of times, it was the poohest of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of credulity, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness

worst belief

slide-109
SLIDE 109

It was the best of times, it was the poohest of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of credulity, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness

worst belief very

slide-110
SLIDE 110

i t _ w a s _ t h e _ p

  • h

e s t _

slide-111
SLIDE 111

i t _ w a s _ t h e _ p

  • h

e s t _ w

slide-112
SLIDE 112

i t _ w a s _ t h e _ p

  • h

e s t _ w

slide-113
SLIDE 113

i t _ w a s _ t h e _ p

  • h

e s t _ w

slide-114
SLIDE 114

i t _ w a s _ t h e _ p

  • h

e s t _ w

slide-115
SLIDE 115

i t _ w a s _ t h e _ p

  • h

e s t _ w r

slide-116
SLIDE 116

i t _ w a s _ t h e _ p

  • h

e s t _ w r

slide-117
SLIDE 117

i t _ w a s _ t h e _ p

  • h

e s t _ w r

slide-118
SLIDE 118

i t _ w a s _ t h e _ p

  • h

e s t _ w r v

slide-119
SLIDE 119

i t _ w a s _ t h e _ p

  • h

e s t _ w r v

slide-120
SLIDE 120

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e

slide-121
SLIDE 121

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e

slide-122
SLIDE 122

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r

slide-123
SLIDE 123

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r

slide-124
SLIDE 124

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r y

slide-125
SLIDE 125

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r y

slide-126
SLIDE 126

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r y _

slide-127
SLIDE 127

i t _ w a s _ t h e _ p

  • h

e s t _ w r v e r y _

slide-128
SLIDE 128

Sometimes it fails.

slide-129
SLIDE 129

What consistency guarantees do both of today's mechanisms provide?

slide-130
SLIDE 130

When are these good?