This document outlines presentations on Amazon's Dynamo and Kai, an open source implementation of Dynamo. It discusses Dynamo's motivation, features, algorithms, and implementation. For Kai, it covers building and running Kai, its internals, and roadmap. Key aspects of Dynamo covered include consistent hashing for partitioning, gossip protocols for membership changes, vector clocks for versioning, and Merkle trees for synchronization.
4. Dynamo: Features
Key, value
P2P
O(1K)
get(“cart/joe”)
joe
joe
joe
08.6.17
5. Dynamo: Features, cont’d
Service Level Agreements
99.9% 300ms
15ms, 30ms
get(“cart/joe”)
(Eventually Consistent)
joe
- RDBMS joe
- Dynamo joe
08.6.17
6. Dynamo: Overview
Dynamo (instance)
joe
bob
N
bob
joe
bob
Dynamo APIs
joe
get(key)
put(key, value, context)
Dynamo of N = 3
memcache cas context
delete
memcache
08.6.17
7. Dynamo: Partitioning
Consistent Hashing 2^128
0
1
2
hash(node5)
hash(node4)
MD5 (128bits)
N
hash(node6)
hash(node2)
hash(node3)
joe
hash(cart/joe)
hash(node1)
Hash ring (N=3)
08.6.17
8. Dynamo: Partitioning, cont’d
2^128
0
1
2
hash(node5)
hash(node4)
N
hash(node6)
hash(node2)
hash(node3)
joe
hash(cart/joe)
hash(node1)
Remapped range
Node2 is down
08.6.17
9. in data center A
Dynamo: Partitioning in data center B
2^128
0
1
2
hash(node5)
hash(node4)
hash(node6)
hash(node2)
hash(node3)
joe
hash(cart/joe)
hash(node1)
joe is replicated in multiple data centers
08.6.17
11. Dynamo: Partitioning, cont’d
2^128
0
1
2
bob and joe are
bob
in same bucket
joe
Merkle
Divided into 8 buckets
08.6.17
12. Dynamo: Membership
Detecting node failure
node2 is down
node2 is down
node2 is down
hash(node2)
node2 is down
Membership change is spread
by the form of gossip
08.6.17
13. Dynamo: Membership, cont’d
Chord
Brown knows only yellows
> O(10K)
O(log v)
Who has “cart/ken”?
v
ken
< O(log v)
Routing in Chord
08.6.17
14. Dynamo: Request
Response
get/put Operations
Client
1.
Coordinator
joe
Consistent hashing N
1.
2.
R W
3.
joe
get
4.
5. joe
get/put operations for N,R,W = 3,2,2
08.6.17
15. Dynamo: Request
Response
get/put Operations, Cont’d
Client
(Quorum)
Coordinator
N:
joe
R:
W:
R+W > N
joe
R<N joe
N,R,W = 3,2,2
get/put operations for N,R,W = 3,2,2
08.6.17
16. Dynamo: Versioning
Vector Clocks
(A:2, C:1) A 2, B 1
Independent
Effect
nodeA
(A:0)
(A:1)
(A:2, C:1)
(A:3, B:1, C:1)
nodeB
(A:1, B:1, C:1)
(A:3, B:2, C:1)
Cause
nodeC
(A:1, C:1)
(A:2, C:2)
Independent
Time
Cause and Effect of version (A:1, B:1, C:1)
08.6.17
17. Dynamo: Versioning, cont’d
Vector Clocks
Vector Clocks
Independent
Effect
nodeA
(A:0)
(A:1)
(A:2, C:1)
(A:3, B:1, C:1)
nodeB
(A:1, B:1, C:1)
(A:3, B:2, C:1)
Cause
nodeC
(A:1, C:1)
(A:2, C:2)
Independent
Time
Cause and Effect of version (A:1, B:1, C:1)
08.6.17
24. Kai: Overview
Kai
Dynamo
OpenDynamo Amazon Dynamo
Erlang
memcache API
http://sourceforge.net/projects/kai/
08.6.17
25. Kai: Building Kai
Erlang OTP (>= R12B)
make
Build
% svn co http://kai.svn.sourceforge.net/svnroot/kai/trunk kai
% cd kai/
% make
% make test
make test Makefile RUN_TEST
MacOSX
./configure
08.6.17
26. Kai: Configuration
kai.config
Parameter
Description
Default value
logfile
hostname
port
API 11011
memcache_port
memcache API 11211
n, r, w
N, R, W
3, 2, 2
number_of_buckets
1024
number_of_virtual_nodes
128
08.6.17
27. Kai: Running Kai
% erl -pa src -config kai -kai n 1 -kai r 1 -kai w 1
1> application:load(kai).
2> application:start(kai).
Arguments
Description
-pa src
src Erlang
-config kai
kai.config
-kai n1 -kai r1 -kai w1
N, R, W = 1, 1, 1
memcache 127.0.0.1:11211
08.6.17
36. Kai: kai_store
gen_server
dets, mnesia, MySQL
Erlang
dets mnesia
ets
4GB
Synopsis
kai_store:start_link(),
# Retrieves Data associated with Key
Data = kai_store:get(Key),
% Stores Data, which is a variable of data record
kai_store:put(Data).
08.6.17