Leveraging Riak’s New Data Types
Conflict-Free Replicated Datatypes
Chris Meiklejohn
@cmeik
EFL Toronto 2013
Slide 4
Slide 4 text
cmeiklejohn
Slide 5
Slide 5 text
Riak Made Consistent
Strong Consistency in Riak 2.0
Tom Santero
@tsantero
EFL Toronto 2013
Slide 6
Slide 6 text
@
basho.com
tsantero
Slide 7
Slide 7 text
Riak Overview
Slide 8
Slide 8 text
Riak Overview
Erlang implementation of Dynamo
Slide 9
Slide 9 text
Riak Overview
Erlang implementation of Dynamo
Slide 10
Slide 10 text
Riak Object
Slide 11
Slide 11 text
Key Value
Slide 12
Slide 12 text
Riak Overview
Consistent hashing
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
Riak Overview
Dynamic membership
Slide 17
Slide 17 text
Riak Overview
Replication factor
Slide 18
Slide 18 text
Replica Replica Replica
Slide 19
Slide 19 text
High Availability
“...any non-failing node can respond to any request”
--Gilbert & Lynch
Slide 20
Slide 20 text
Eventual Consistency
“Eventual consistency is a consistency model used in
distributed computing that informally guarantees that, if no
new updates are made to a given data item, eventually all
accesses to that item will return the last updated value.”
--Wikipedia
This project is funded by the European Union,
7th Research Framework Programme, ICT call 10,
grant agreement n°609551.
Slide 83
Slide 83 text
No content
Slide 84
Slide 84 text
Strong Consistency
Slide 85
Slide 85 text
Strong Consistency
Why?
Slide 86
Slide 86 text
Strong Consistency
Why? atomicity
Slide 87
Slide 87 text
Strong Consistency
Why? recency
Slide 88
Slide 88 text
Strong Consistency
Why? partial writes
Slide 89
Slide 89 text
A A A
Slide 90
Slide 90 text
A A A
Val = <<“B”>>.
Slide 91
Slide 91 text
A A A
Val = <<“B”>>.
Slide 92
Slide 92 text
B A A
Slide 93
Slide 93 text
B A A
riakc_pb_socket:get(PBC, <<“Bucket”>>, <<“Key”>>).
Slide 94
Slide 94 text
B A A
riakc_pb_socket:get(PBC, <<“Bucket”>>, <<“Key”>>).
Slide 95
Slide 95 text
B A A
riakc_pb_socket:get(PBC, <<“Bucket”>>, <<“Key”>>).
B B
Slide 96
Slide 96 text
Strong Consistency
Single key atomic operations
Slide 97
Slide 97 text
Strong Consistency
any get sees most recent put
Slide 98
Slide 98 text
Strong Consistency
get/modify/put cycle fails if object is changed
Slide 99
Slide 99 text
Strong Consistency
put w/o vclock fails if object exists
Slide 100
Slide 100 text
Consensus
Slide 101
Slide 101 text
Distributed Consensus
“The problem of reaching agreement among remote
processes is one of the most fundamental problems in
distributed computing and is at the core of many
algorithms for distributed data processing, distributed
file management, and fault-tolerant distributed
applications.”
--Fischer, Lynch, Paterson
Get Operations
leader reads local object; if Epoch old: refresh
Slide 139
Slide 139 text
Node 1 Node 2 Node 3
obj.epoch < epoch
get(key)
reply(Epoch , Seq , Val )
b
Val = latest(Val , Val , Val )
Val.epoch = epoch
write(Epoch, ++Seq, Val)
ack(Epoch, Seq)
b b
reply(Epoch , Seq , Val )
c c c
a b c
Get Operations
Worst Case: 2 roundtrips / request
Best Case: 0 roundtrips / request
Slide 142
Slide 142 text
Put Operations
leader reads local object; if Epoch old: refresh
modify object
commit modified object
Slide 143
Slide 143 text
Node 1 Node 2 Node 3
obj.epoch < epoch
get(key)
reply(Epoch , Seq , Val )
b
Latest = latest(Val , Val , Val )
Val = modify(Latest)
write(Epoch, ++Seq, Val)
ack(Epoch, Seq)
b b
reply(Epoch , Seq , Val )
c c c
a b c