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
670
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
136
6.6k
Elixir and Ecto
vanstee
5
820
Bootstrap
vanstee
8
710
HTTP API Design for iOS Applications
vanstee
11
540
Consensus: An Introduction to Raft
vanstee
22
2.8k
Pour Over Brewing Method
vanstee
1
290
Celluloid & DCell
vanstee
4
470
Map Reduce & Ruby
vanstee
10
700
Other Decks in Programming
See All in Programming
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
120
ACES Meet におけるリリース作業改善の取り組み
fukucheee
0
130
Kotlin Multiplatform at Stable and Beyond (Kotlin Vienna, October 2024)
zsmb
2
360
perl for shell, awk and sed programmers
mackee
1
700
2024-10-01 dev2next - Observability for Modern JVM Applications
jonatan_ivanov
0
130
学生の時に開催したPerl入学式をきっかけにエンジニアが組織に馴染むために勉強会を主催や仲間と参加して職能間の境界を越えていく
ohmori_yusuke
1
130
RemixとCloudflare Stack におけるFile Upload
ossamoon
1
130
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
6
690
Introduce dRuby
ledsun
0
110
Cancel Next.js Page Navigation: Full Throttle
ypresto
1
190
Remix × Cloudflare Pages × Sentry 奮闘記 / remix-pages-sentry
nkzn
1
420
自分だけの世界を創るクリエイティブコーディング / Creative Coding: Creating Your Own World
chobishiba
2
1.2k
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
KATA
mclloyd
27
13k
Documentation Writing (for coders)
carmenintech
65
4.4k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
Visualization
eitanlees
143
15k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Music & Morning Musume
bryan
46
6.1k
Facilitating Awesome Meetings
lara
49
6k
Gamification - CAS2011
davidbonilla
80
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