consistency without consensus crdts in production at
play

Consistency without consensus: CRDTs in production at SoundCloud - PowerPoint PPT Presentation

Consistency without consensus: CRDTs in production at SoundCloud Consistency without consensus: CRDTs in production at SoundCloud Me Some guy Embedded, sensor networks Distributed systems SoundCloud infrastructure Theory Distributed


  1. Consistency without consensus: 
 CRDTs in production at SoundCloud

  2. Consistency without consensus: 
 CRDTs in production at SoundCloud

  3. Me Some guy Embedded, sensor networks Distributed systems SoundCloud infrastructure

  4. Theory

  5. Distributed programming “The art of solving the same problem that 
 you can solve on a single computer 
 using multiple computers.” 
 — book.mixu.net

  6. Distributed programming “Generally a bad idea, 
 best avoided.” 
 — me

  7. >>> x = 1 >>> print x 1

  8. $ curl -XPOST -d'{"val": 1}' http://db/vars/x HTTP 502 Bad Gateway $ curl -XGET http://db/vars/x HTTP 503 Service Unavailable

  9. Idioms

  10. 1980s — RPC

  11. 1990s — CORBA

  12. 2000 — CAP

  13. Partition tolerance “The system continues to operate despite message loss due to network and/or node failure.” 
 —book.mixu.net

  14. CP AP Partition 
 tolerance ✗ Consistency Availability

  15. CP Chubby, Doozer — Paxos ZooKeeper — Zab Consul, etcd — Raft ? — Viewstamped Replication

  16. AP Cassandra Riak Mongo Couch

  17. Message failure Delayed Dropped Delivered out-of-order Duplicated

  18. CALM principle Consistency As Logical Monotonicity

  19. ACID 2.0 Associative Commutative Idempotent Distributed, sure, whatever

  20. CRDT Conflict-free Replicated Data Type

  21. Increment-only 
 counter

  22. A' A → A'

  23. + (1 + 2) + 3 = 1 + (2 + 3) 1 + 2 = 2 + 1 1 + 1 ≠ 1

  24. ∪ ( 1 ∪ 2 ) ∪ 3 = 1 ∪ ( 2 ∪ 3 ) 1 ∪ 2 = 2 ∪ 1 1 ∪ 1 = 1

  25. { } { } { }

  26. { } 123 { } { }

  27. { } 123 { } 123 { }

  28. { } 123 { } 123 { }

  29. { } 123 { } 123 { } 123

  30. { } 123 { } 123 { } 123

  31. { } 123 { } 123 456 { } 123

  32. { } 123 { } 123 456 { } 123, 456

  33. { } 123 { } 123 ✘ { } 123, 456

  34. { } 123, 456 { } 123 { } 123, 456

  35. { } 123, 456 { } 123 { } 123, 456

  36. Read {123, 456} ∪ {123} ∪ {123, 456} = {123, 456} 
 {123, 456} ∆ {123} ∆ {123, 456} = {456}

  37. { } 456 123, 456 { } 123 { } 123, 456

  38. { } 123, 456 { } 123, 456 { } 123, 456

  39. { } 123, 456 { } 123, 456 { } 123, 456

  40. { } 123, 456 { } 123, 456 { } 123, 456

  41. Interlude — 
 Bending the problem

  42. CRDTs in production

  43. Event Timestamp Actor Verb Thing

  44. Event 2014-04-01T15:16:17.187Z snoopdogg reposted theeconomist/election-day

  45. Fan out on write ●●●● ( • ི ̛ᴗ • ̛ ) ྀ ● ༼ ⍢ ༽ ● ● ●●● ༼ • ͟ ͜ • ༽ ● ●●●●● ( ಠ _ ಠ ) ●

  46. Fan in on read [¬º-°] ••• ( • ི ̛ᴗ • ̛ ) ྀ ༼ • ͟ ͜ • ༽ •••••• ༼ ⍢ ༽ ••••• ( ಠ _ ಠ )

  47. Unique events — use a set G-set — can’t delete 2P-set — add, remove once OR-set — storage overhead

  48. A wild set appears

  49. Roshi set S+ { A/1 B/2 C/3 } S– { D/4 } S { A B C }

  50. Roshi set S = actor’s outbox key 
 snoopdogg·outbox A/B/C/D = actor+verb+thing 
 snoopdogg·repost·theeconomist/election-day 1/2/3 = timestamp 
 2014-04-01T15:16:17.187Z

  51. Reading is easy

  52. Writing is interesting

  53. Insert • If either key + or key – already contains element , 
 and the existing score >= score , 
 no-op and exit . • Insert ( element, score ) into add set key +. • Delete ( element ) from remove set key –.

  54. Delete • If either key + or key – already contains element , 
 and the existing score >= score , 
 no-op and exit . • Insert ( element, score ) into add set key– . • Delete ( element ) from remove set key+ .

  55. Example

  56. S+ { A/1 B/2 } S– { C/3 }

  57. Insert D/4 S+ { A/1 B/2 } S– { C/3 }

  58. Insert D/4 S+ { A/1 B/2 D/4 } S– { C/3 }

  59. S+ { A/1 B/2 D/4 } S– { C/3 }

  60. Insert D/4 S+ { A/1 B/2 D/4 } S– { C/3 }

  61. Insert D/4 S+ { A/1 B/2 D/4 } S– { C/3 }

  62. S+ { A/1 B/2 D/4 } S– { C/3 }

  63. Delete D/3 S+ { A/1 B/2 D/4 } S– { C/3 }

  64. Delete D/3 S+ { A/1 B/2 D/4 } S– { C/3 }

  65. S+ { A/1 B/2 D/4 } S– { C/3 }

  66. Delete D/5 S+ { A/1 B/2 D/4 } S– { C/3 }

  67. Delete D/5 S+ { A/1 B/2 D/4 } S– { C/3 D/5 }

  68. S+ { A/1 B/2 } S– { C/3 D/5 }

  69. Delete D/6 S+ { A/1 B/2 } S– { C/3 D/5 }

  70. Delete D/6 S+ { A/1 B/2 } S– { C/3 D/6 }

  71. S+ { A/1 B/2 } S– { C/3 D/6 }

  72. Making it real

  73. Pool Cluster

  74. Pool Pool Pool Cluster Cluster Cluster Farm

  75. Writing is easy

  76. Reading is interesting

  77. Pool Pool Pool Cluster Cluster Cluster Farm

  78. Pool Pool Pool Cluster Cluster Cluster Farm

  79. Cluster Cluster Cluster {A B C} {A C} {A B C} ∪ = {A B C} ∆ = {B}

  80. Pool Pool Pool Cluster Cluster Cluster Farm

  81. github.com/soundcloud/roshi

  82. In conclusion,

  83. Consistency without consensus = CRDT. 
 Embrace your invariants. 
 Maybe bend your problem, not your solution.

  84. Thanks! ☞ ☜ soundcloud.com/jobs @peterbourgon

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend