Convergent Replicated Data Types

Convergent Replicated Data Types

B6a8f005f39d23ffc930508ac9da68b9?s=128

Patrick Van Stee

December 14, 2012
Tweet

Transcript

  1. Convergent Replicated Data Types

  2. @vanstee vanstee@bignerdranch.com Patrick Van Stee

  3. “Structuring data so conflict resolution is automatic”

  4. Dynamo Trade consistency 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

  11. 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}
  12. What about decrements? Use separate counters for positive and negative.

    Take the difference for the result.
  13. 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 }
  14. Set •Can only be added to •Merge: take the union

  15. Serious Business { PVS: [ ] } Serious Coding {

    PVS: [] } { PVS: [] } { PVS: [ ] } Merge { PVS: [ , ] } { PVS: [ , ] } { PVS: [ , , ] } { PVS: [ , , ] }
  16. Hold on, Can we remove stuff? Use separate sets for

    added and removed elements.
  17. Serious Business { 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