Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Convergent Replicated Data Types
Patrick Van Stee
December 14, 2012
Programming
4
460
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
127
5.5k
Elixir and Ecto
vanstee
4
570
Bootstrap
vanstee
8
540
HTTP API Design for iOS Applications
vanstee
11
380
Consensus: An Introduction to Raft
vanstee
22
2.1k
Pour Over Brewing Method
vanstee
1
130
Celluloid & DCell
vanstee
4
280
Map Reduce & Ruby
vanstee
10
500
Other Decks in Programming
See All in Programming
料理の注文メニューの3D化への挑戦
hideg
0
290
実践 SpiceDB - クライドネイティブ時代をサバイブできるパーミッション管理の実装を目指して / Practical SpiceDB
lmt_swallow
0
130
パラメタライズドテスト
ledsun
0
220
NestJS_meetup_atamaplus
atamaplus
0
210
アジャイルで始める データ分析基盤構築
nagano
1
900
Git操作編
smt7174
2
250
20220706_Google Apps Scriptを実演で学ぶ~ GAS × Slack ~
apachan
2
620
Cloudflare WorkersでGoのHTTPサーバーを動かすライブラリを作った話
syumai
0
150
Isar勉強会
hoddy3190
0
470
kintone × LINE Bot で餃子検定Botを作った話
naberina
0
330
테라폼으로 ECR 관리하기 (How to Manage ECR with Terraform)
posquit0
0
530
Untangling Coroutine Testing (Droidcon Berlin 2022)
zsmb
1
480
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
47
7.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
15k
Debugging Ruby Performance
tmm1
65
10k
Designing for humans not robots
tammielis
241
24k
Web development in the modern age
philhawksworth
197
9.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
223
49k
Thoughts on Productivity
jonyablonski
44
2.4k
Bootstrapping a Software Product
garrettdimon
296
110k
GitHub's CSS Performance
jonrohan
1020
420k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
Making the Leap to Tech Lead
cromwellryan
113
7.4k
Done Done
chrislema
174
14k
Transcript
Convergent Replicated Data Types
@vanstee vanstee@bignerdranch.com 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