Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Convergent Replicated Data Types
Search
Patrick Van Stee
December 14, 2012
Programming
4
700
Convergent Replicated Data Types
Patrick Van Stee
December 14, 2012
Tweet
Share
More Decks by Patrick Van Stee
See All by Patrick Van Stee
Raft: Consensus for Rubyists
vanstee
137
6.7k
Elixir and Ecto
vanstee
5
870
Bootstrap
vanstee
8
740
HTTP API Design for iOS Applications
vanstee
11
580
Consensus: An Introduction to Raft
vanstee
22
2.9k
Pour Over Brewing Method
vanstee
1
320
Celluloid & DCell
vanstee
4
510
Map Reduce & Ruby
vanstee
10
740
Other Decks in Programming
See All in Programming
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.2k
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
170
VisionProで部屋の明るさを反映させるシェーダーを作った話
segur
0
100
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
300
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
rails newと同時に型を書く
aki19035vc
5
710
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
540
Оптимизируем производительность блока Казначейство
lamodatech
0
950
functionalなアプローチで動的要素を排除する
ryopeko
1
190
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
1.2k
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
930
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
370
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
Scaling GitHub
holman
459
140k
Gamification - CAS2011
davidbonilla
80
5.1k
Why Our Code Smells
bkeepers
PRO
335
57k
The Invisible Side of Design
smashingmag
299
50k
Bash Introduction
62gerente
610
210k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Statistics for Hackers
jakevdp
797
220k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Music & Morning Musume
bryan
46
6.3k
How to train your dragon (web standard)
notwaldorf
89
5.8k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Transcript
Convergent Replicated Data Types
@vanstee
[email protected]
Patrick Van Stee
“Structuring data so conflict resolution is automatic”
Dynamo Trade consistency for availability and partition tolerance
Node 1 Node 2 { a: “200” } { a:
“-3000” } :(
Node 1 Node 2 { a: “200” } { a:
“-3000” } { a: “200”, a: “-3000” } Riak
CRDT •Counter •Set •Graph •List •Tree
CRDT •Counter •Set •Graph •List •Tree
Counter •Can only be increased •Merge: use largest value
Chat Room Karma Fault-Tolerant Distributed
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}
What about decrements? Use separate counters for positive and negative.
Take the difference for the result.
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 }
Set •Can only be added to •Merge: take the union
Serious Business { PVS: [ ] } Serious Coding {
PVS: [] } { PVS: [] } { PVS: [ ] } Merge { PVS: [ , ] } { PVS: [ , ] } { PVS: [ , , ] } { PVS: [ , , ] }
Hold on, Can we remove stuff? Use separate sets for
added and removed elements.
Serious Business { PVS+: [ ], PVS-: [] } Serious
Coding { PVS+: [], PVS-: [] } { PVS+: [], PVS-: [] } { PVS+: [ ], PVS-: [] } Merge { PVS+: [ , ], PVS-: [ ] } { PVS+: [ ], PVS-: [ ] } { PVS+: [ , ], PVS-: [] } { PVS+: [ , ], PVS-: [ ] } { PVS: [ ] }
But wait, we can only remove once?
U-Set •Append unique values to all set members •Garbage collection
becomes an issue
basho/riak_dt Demo
Use Cases •Like button •Page Views •Shopping Cart
Reference •INRIA paper •basho/riak_dt •RICON talk
Beginning Ruby on Rails Course bignerdranch.com/classes/beginning_ruby_on_rails