Patrick Van Stee
December 14, 2012
590

# Convergent Replicated Data Types

## Patrick Van Stee

December 14, 2012

## Transcript

1. Convergent
Replicated
Data Types

2. @vanstee
[email protected]
Patrick Van Stee

3. “Structuring
data so conflict
resolution is
automatic”

4. Dynamo
for availability and
partition tolerance

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

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

7. CRDT
•Counter
•Set
•Graph
•List
•Tree

8. CRDT
•Counter
•Set
•Graph
•List
•Tree

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

10. Chat Room
Karma
Fault-Tolerant
Distributed

{ 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}

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

{ 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 }

14. Set
•Merge: take the union

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

16. Hold on, Can
we remove
stuff?
and removed elements.

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

18. But wait,
we can only
remove once?

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

20. basho/riak_dt
Demo

21. Use Cases
•Like button
•Page Views
•Shopping Cart

22. Reference
•INRIA paper
•basho/riak_dt
•RICON talk

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