Successfully reported this slideshow.
Upcoming SlideShare
×

# CRDTs for engineers

779 views

Published on

Published in: Technology, Design
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### CRDTs for engineers

1. 1. CRDTsfor engineers1Thursday, June 27, 13
2. 2. CRDT• Conﬂict-Free (amongst others)• Replicated• Data• Type2Thursday, June 27, 13
3. 3. CRDT• Conﬂict-Free (amongst others)• Replicated• Data - obvious• Type - obvious3Thursday, June 27, 13
4. 4. Replicated• Build to be used in distributed systems• multiple replicas can be changedconcurrently• do not require locking4Thursday, June 27, 13
5. 5. Conﬂict-Free• the big one!• replica merges with predictable behavior!• predictable =:= desired?5Thursday, June 27, 13
6. 6. big words• Associative• Commutative• Idempotent6Thursday, June 27, 13
7. 7. Associative• operations can be applied in any order• x ∧ (y ∧ z) = (x ∧ y) ∧ z7Thursday, June 27, 13
8. 8. Commutative• The values of operations can be swapped.• x ∧ y = y ∧ x• together• we don’t need to care about order8Thursday, June 27, 13
9. 9. Idempotent• not impotent!• applying twice does not change a thing.• f(f(x)) = f(x)9Thursday, June 27, 13
10. 10. Types• CmRDT message based• CvRDT state based (v for vector)• can be emulated10Thursday, June 27, 13
11. 11. CmRDT• based on messages• requires messages to be delivered• needs controls of messages (complex)11Thursday, June 27, 13
12. 12. CvRDT• Based on the objects state• independent from underlaying structure• that’s good!12Thursday, June 27, 13
13. 13. LWW registerVaTa VbTbVbTbTa =< Tb13Thursday, June 27, 13
14. 14. G SetM1 Merge M214Thursday, June 27, 13
15. 15. G SetAM1 Merge M2AA15Thursday, June 27, 13
16. 16. G SetAM1 Merge M2AA16Thursday, June 27, 13
17. 17. G SetAM1 Merge M2AAB B17Thursday, June 27, 13
18. 18. G SetAM1 Merge M2AAB B18Thursday, June 27, 13
19. 19. G SetAM1 Merge M2AAB B CC19Thursday, June 27, 13
20. 20. G SetAM1 Merge M2AAB B CC20Thursday, June 27, 13
21. 21. G SetAM1 Merge M2AAB B CCD DDUnion21Thursday, June 27, 13
22. 22. G CounterMaster 1Master 2Master 30 0 00 0 00 0 0M1 M2 Merge000M30 0 0 0= Max= Max= MaxSumSumSumSum22Thursday, June 27, 13
23. 23. G CounterMaster 1Master 2Master 31 1 10 0 00 0 0M1 M2 Merge100M31 1 1 1= Max= Max= MaxSumSumSumSum23Thursday, June 27, 13
24. 24. G CounterMaster 1Master 2Master 31 1 14 4 40 0 0M1 M2 Merge140M35 5 5 5= Max= Max= MaxSumSumSumSum24Thursday, June 27, 13
25. 25. G CounterMaster 1Master 2Master 31 1 14 4 40 0 0M1 M2 Merge140M35 5 5 5= Max= Max= MaxSumSumSumSum25Thursday, June 27, 13
26. 26. G CounterMaster 1Master 2Master 31 1 14 4 45 0 5M1 M2 Merge145M310 5 10 10= Max= Max= MaxSumSumSumSum26Thursday, June 27, 13
27. 27. G CounterMaster 1Master 2Master 31 1 14 4 45 0 5M1 M2 Merge145M310 5 10 10= Max= Max= MaxSumSumSumSum27Thursday, June 27, 13
28. 28. G CounterMaster 1Master 2Master 31 1 14 4 45 0 5M1 M2 Merge145M310 5 10 10= Max= Max= MaxSumSumSumSum28Thursday, June 27, 13
29. 29. G CounterMaster 1Master 2Master 31 1 14 4 45 7 7M1 M2 Merge147M310 12 12 12= Max= Max= MaxSumSumSumSum29Thursday, June 27, 13
30. 30. G CounterMaster 1Master 2Master 31 1 14 4 45 7 7M1 M2 Merge147M310 12 12 12= Max= Max= MaxSumSumSumSum30Thursday, June 27, 13
31. 31. now it’s like lego31Thursday, June 27, 13
32. 32. PN CounterIncrements DecrementsG Counter G Counter32Thursday, June 27, 13
33. 33. 2P SetAdditions DeletionsG Set G Set33Thursday, June 27, 13
34. 34. 2P Set• Can only be added once• Deleted for good34Thursday, June 27, 13
35. 35. 35Thursday, June 27, 13
36. 36. PN Set7 A0 B3 C-2 DPN CounterAC36Thursday, June 27, 13
37. 37. PN Set• Partial merges can lead to negative values• Adds might (temporarily) have no effect37Thursday, June 27, 13
38. 38. OR SetM1,1 AM1,1 AM2,1 AM1,2 BM1,3 AAB2P Set38Thursday, June 27, 13
39. 39. OR Set39Thursday, June 27, 13
40. 40. OR SetM1,1 A M1,1 A A40Thursday, June 27, 13
41. 41. OR SetM1,1 A M1,1 A AM1,2 B B41Thursday, June 27, 13
42. 42. OR SetM1,1 A M1,1 A AM1,2 B BM2,1 B42Thursday, June 27, 13
43. 43. OR SetM1,1 A M1,1 A AM1,2 B BM2,1 BM1,2 B43Thursday, June 27, 13
44. 44. OR SetM1,1 A M1,1 A AM1,2 B BM2,1 BM1,2 BM1,3 B44Thursday, June 27, 13
45. 45. OR SetM1,1 A M1,1 A AM1,2 B M2,1 BM1,2 BM1,3 BM2,1 BM1,3 BM2,1 BM1,3 B45Thursday, June 27, 13
46. 46. OR Set• Elements have a unique ID• delete• Elements might ‘reappear’ after a merge• lots of trash46Thursday, June 27, 13
47. 47. Questions?• Code?• C-x C-+• https://github.com/Licenser/ecrdt• more links there!47Thursday, June 27, 13