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
860
Bootstrap
vanstee
8
730
HTTP API Design for iOS Applications
vanstee
11
570
Consensus: An Introduction to Raft
vanstee
22
2.8k
Pour Over Brewing Method
vanstee
1
310
Celluloid & DCell
vanstee
4
500
Map Reduce & Ruby
vanstee
10
730
Other Decks in Programming
See All in Programming
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
670
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
.NET 9アプリをCGIとして レンタルサーバーで動かす
mayuki
1
770
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
200
Criando Commits Incríveis no Git
marcelgsantos
2
170
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Practical Orchestrator
shlominoach
186
10k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
KATA
mclloyd
29
14k
Being A Developer After 40
akosma
87
590k
Six Lessons from altMBA
skipperchong
27
3.5k
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