Top Banner
Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang [email protected]
26

Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang [email protected]

Feb 17, 2018

Download

Documents

trinhdien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Amazon DynamoA Highly Available Key-value Store

Present by Jian Fang

[email protected]

Page 2: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

What is Dynamo

Eventually consistent key-value store

Support scalable highly available data access

Optimized for availability to maximize customer satisfaction

Page 3: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Why not RDBMS?

Only need primary-key access

RDBMS have limited scalability

RDBMS require expensive hardware and skillful administrators

Page 4: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Amazon’s Requirements

Objects are less than 1MB

No operations span for multiple data

<300ms response time for 99.9% requests

Heterogeneous commodity hardware infrastructure

Decentralized, loosely coupled services

Highly available(always writable)

Page 5: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Techniques used in Dynamo

Consistent Hashing

Vector clocks

Sloppy Quorum and Hinted handoff

Merkle trees

Gossip-based membership protocol

Page 6: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Interfaces

Key-value storage system with operators:

Get(key): return a single or a list of objects with conflicting versions

Put(key, context, object): context contains the version information

MD5 hashing is applied on the key to generate 128-bit identifier

Page 7: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Partitioning

Scale Incrementally

Consistent Hashing

Variant of Consistent Hashing

Page 8: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Consistent Hashing

Simple Non-Consistent Hashing

𝐻𝑎𝑠ℎ 𝑘𝑒𝑦 𝑚𝑜𝑑 𝑁

What if N = N + 1

6 keys(a half) remapped

Consistent Hashing

Only K/N keys need to be remapped

12 keys, N = 3

S1 S2 S3

12 keys, N = 4

S1 S2 S3 S4

Page 9: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Consistent Hashing

A

B

C

Key X

D

Key Z

Key Y

Page 10: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Consistent Hashing

Not good enough

Non-uniform load distribution

No heterogeneity in node’s performance

Variant of Consistent Hashing

Virtual Nodes

Page 11: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Variant of Consistent Hashing

Q = 12 (Virtual Nodes)

S = 3 (Physical Nodes)

T = Q/S = 4 (Tokens)

S1

S1

S1

S1

S2

S2

S2

S2

S3

S3S3

S3

Page 12: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Variant of Consistent Hashing

Q = 12 (Virtual Nodes)

S = 4 (Physical Nodes)

T = Q/S = 4 (Tokens)

S1

S4

S1

S1

S2

S2

S4

S2

S3

S3S3

S4

S1

S2

S3

Page 13: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Replication

A coordinator Node(i)

(N-1) clockwise successor nodes as replicas

Node(i) update all other (N-1) replicas

A preference list of nodes

List size > N

A

B

C

Key Z

D

Node(i)

Preference List = [A,B,C,D]

Page 14: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Data Versioning

Eventual Consistency

Put() is returned before updating all replicas

Get() can return multiple versions for the same key

Data mutation as new version

Vector Clock

Page 15: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

Supplier A

500$

500$(1,0,0) 500$(1,0,0) 500$(1,0,0)

Page 16: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

Supplier A

550$

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

Page 17: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

600$

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

Supplier B

600$(2,1,0)

Page 18: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

650$

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

Supplier C

600$(2,1,0) 650$(2,0,1)650$(2,0,1) 650$(2,0,1)

Conflict!

Page 19: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

Supplier B

600$(2,1,0) 650$(2,0,1)650$(2,0,1) 650$(2,0,1)

600$(2,1,0)/650$(2,0,1)

Resolve Conflict

Choose 650$

Page 20: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Vector Clock(Example)

Sx Sy Sz

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

500$(1,0,0)

550$(2,0,0)

Supplier B

600$(2,1,0)/650$(2,0,1) 650$(2,0,1)650$(2,0,1)

650$(2,1,1)

650$(2,1,1)650$(2,1,1) 650$(2,1,1)

Page 21: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Processing get() and put()

How to select a coordinator node

Load balancer (server-driven)

Partition aware client library (client-driven)

Quorum-like system for consistency

W + R > N

Typical value: W=2 R=2 N=3

N

W R

Page 22: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Hinted Handoff

A

B

C

Put()

DA

Page 23: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Hinted Handoff

A

B

C

DA

Page 24: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Replica Synchronization(Merkle Tree)

(128,160]

0x1100

(160,192]

0x0111

(192,224]

0

(224,256]

0

(0,32]

0x1001

(32,64}

0

(64,96}

0

(96,128]

0

32

0x1001

96

0

160

0x1011

224

0

64

0x1001

192

0x1011

128

0x0010

XOR

XOR XOR

XOR XOR XOR XOR

Row key1 Row key2 Row key3 Row key4

Token: 5 Token: 135 Token: 170 Token: 185

Hash: 0x1001 Hash: 0x1100 Hash: 0x0101 Hash: 0x0010

Range: (0,256]

Depth: 3

Tokens: 8 * 32

Example from: http://bit.ly/1fUa0CS

Page 25: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Performance

Page 26: Amazon Dynamopavlo/courses/fall2013/static/slides/dynamo.pdf · Amazon Dynamo A Highly Available Key-value Store Present by Jian Fang jianf@cmu.edu

Q&A

Thank you!