Slide 1

Slide 1 text

Convergent Replicated Data Types

Slide 2

Slide 2 text

@vanstee [email protected] Patrick Van Stee

Slide 3

Slide 3 text

“Structuring data so conflict resolution is automatic”

Slide 4

Slide 4 text

Dynamo Trade consistency for availability and partition tolerance

Slide 5

Slide 5 text

Node 1 Node 2 { a: “200” } { a: “-3000” } :(

Slide 6

Slide 6 text

Node 1 Node 2 { a: “200” } { a: “-3000” } { a: “200”, a: “-3000” } Riak

Slide 7

Slide 7 text

CRDT •Counter •Set •Graph •List •Tree

Slide 8

Slide 8 text

CRDT •Counter •Set •Graph •List •Tree

Slide 9

Slide 9 text

Counter •Can only be increased •Merge: use largest value

Slide 10

Slide 10 text

Chat Room Karma Fault-Tolerant Distributed

Slide 11

Slide 11 text

Serious Business { SB[PVS]: 0} Serious Coding { SB[PVS]: 1} # PVS++ { SC[PVS]: 0} { SC[PVS]: 5} # PVS += 5 { SB[PVS]: 2} # PVS++ Merge { SB[PVS]: 2, SC[PVS]: 5} { SB[PVS]: 1, SC[PVS]: 5} { SB[PVS]: 2, SC[PVS]: 5} { PVS: 7}

Slide 12

Slide 12 text

What about decrements? Use separate counters for positive and negative. Take the difference for the result.

Slide 13

Slide 13 text

Serious Business { SB[PVS+]: 0, SB[PVS-]: 0 } Serious Coding { SB[PVS+]: 1, SB[PVS-]: 0 } # PVS++ { SB[PVS+]: 0, SB[PVS-]: 0 } { SB[PVS+]: 5, SB[PVS-]: 0 } # PVS += 5 { SB[PVS+]: 1, SB[PVS-]: 1 } # PVS-- Merge { PVS+: 6, PVS-: 1 } { PVS+: 6, PVS-: 0 } { PVS+: 6, PVS-: 1 } { PVS: 5 }

Slide 14

Slide 14 text

Set •Can only be added to •Merge: take the union

Slide 15

Slide 15 text

Serious Business { PVS: [ ] } Serious Coding { PVS: [] } { PVS: [] } { PVS: [ ] } Merge { PVS: [ , ] } { PVS: [ , ] } { PVS: [ , , ] } { PVS: [ , , ] }

Slide 16

Slide 16 text

Hold on, Can we remove stuff? Use separate sets for added and removed elements.

Slide 17

Slide 17 text

Serious Business { PVS+: [ ], PVS-: [] } Serious Coding { PVS+: [], PVS-: [] } { PVS+: [], PVS-: [] } { PVS+: [ ], PVS-: [] } Merge { PVS+: [ , ], PVS-: [ ] } { PVS+: [ ], PVS-: [ ] } { PVS+: [ , ], PVS-: [] } { PVS+: [ , ], PVS-: [ ] } { PVS: [ ] }

Slide 18

Slide 18 text

But wait, we can only remove once?

Slide 19

Slide 19 text

U-Set •Append unique values to all set members •Garbage collection becomes an issue

Slide 20

Slide 20 text

basho/riak_dt Demo

Slide 21

Slide 21 text

Use Cases •Like button •Page Views •Shopping Cart

Slide 22

Slide 22 text

Reference •INRIA paper •basho/riak_dt •RICON talk

Slide 23

Slide 23 text

Beginning Ruby on Rails Course bignerdranch.com/classes/beginning_ruby_on_rails