replicated data consistency in the cloud

27
Replicated Data Consistency in the Cloud Doug Terry Microsoft Research Silicon Valley Explained through Baseball

Upload: lindley

Post on 24-Feb-2016

42 views

Category:

Documents


0 download

DESCRIPTION

Replicated Data Consistency in the Cloud . Explained through Baseball. Doug Terry Microsoft Research Silicon Valley. Data Replication in the Cloud. remote datacenter. datacenter. remote secondaries. secondaries. remote primary. primary. Read. Read. Write. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Replicated Data  Consistency  in the Cloud

Replicated Data Consistency in the Cloud

Doug Terry

Microsoft Research Silicon Valley

Explained through Baseball

Page 2: Replicated Data  Consistency  in the Cloud
Page 3: Replicated Data  Consistency  in the Cloud

Data Replication in the Cloud

primary

secondariesdatacenter

remoteprimary

remote secondaries

remote datacenter

Read ReadWrite

e.g. Windows Azure, Amazon S3, Google App Engine...

Page 4: Replicated Data  Consistency  in the Cloud

Questions for Today’s Talk

1. What consistency choices do storage systems offer?

2. What might they offer?

3. Why are these choices useful?

Page 5: Replicated Data  Consistency  in the Cloud

Some Popular Systems

• Amazon S3 – eventual consistency• Amazon Simple DB – eventual or strong• Google App Engine – strong or eventual• Yahoo! PNUTS – eventual or strong• Windows Azure Storage – strong or eventual• Cassandra – eventual or strong (if R+W > N)• ...

5

Page 6: Replicated Data  Consistency  in the Cloud

A Spectrum of Consistency

StrongConsistency

EventualConsistency

IntermediateConsistency

Lots of consistencies proposed in research community: probabilistic quorums, session guarantees, epsilon serializability, fork consistency, causal consistency, demarcation, continuous consistency, ...

Page 7: Replicated Data  Consistency  in the Cloud

My FavoriteRead Consistency Guarantees

Strong Consistency See all previous writes.

Eventual Consistency See subset of previous writes.

Consistent Prefix See initial sequence of writes.

Monotonic Freshness See increasing subset of writes.

Read My Writes See all writes performed by reader.

Bounded Staleness See all “old” writes.

Page 8: Replicated Data  Consistency  in the Cloud

The Game of Baseball for inning = 1 .. 9 outs = 0; while outs < 3 visiting player bats; for each run scored score = Read (“visitors”); Write (“visitors”, score + 1); outs = 0; while outs < 3 home player bats; for each run scored score = Read (“home”); Write (“home”, score + 1); end game;

Page 9: Replicated Data  Consistency  in the Cloud

Strong Consistencyaka linearizability, one-copy serializability

Under the covers:• read-any/write-all

or quorums • 2-phase commit• primary copy

home: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2 2Visitors

5Home

Reader #1

2Visitors

5Home

Reader #2

Report card: Consistency A Performance D Availability F

2Visitors

5Home

Guarantee: See all previous writes.

Page 10: Replicated Data  Consistency  in the Cloud

Eventual Consistencyaka weak/relaxed/optimistic/lazy consistency

Under the covers:• update anywhere or

primary copy• arbitrary write

propagation• read tentative data

from any replicahome: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2 1Visitors

3Home

Reader #1

2Visitors

2Home

Reader #2

Report card: Consistency D Performance A Availability A

2Visitors

5Home

Guarantee: See subset of previous writes; eventually see all writes.

Page 11: Replicated Data  Consistency  in the Cloud

Consistent Prefixaka ordered delivery, snapshot isolation

Under the covers:• update primary

or anywhere• ordered writes• read committed

data from any replica

home: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2 1Visitors

2Home

Reader #1

2Visitors

3Home

Reader #2

Report card: Consistency C Performance B Availability A

2Visitors

5Home

Guarantee: See initial sequence of writes.

Page 12: Replicated Data  Consistency  in the Cloud

Bounded Stalenessaka periodic snapshots, continuous consistency

Under the covers:• primary replica• bounded delivery to

secondary replicas• or check on read

home: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2 1Visitors

3Home

Reader #1

1Visitors

4Home

Reader #2

Report card: Consistency B Performance C Availability D

2Visitors

5Home

Guarantee: See all “old” writes. variants: bounds on data values, log, etc.

old

new

Page 13: Replicated Data  Consistency  in the Cloud

Monotonic Freshnessaka session guarantees

Under the covers:• update anywhere

or primary copy• client records

read-set• restrict reads to

sufficiently up-to-date replicas

home: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2

1Visitors

2Home

Reader #1 at time t1

2Visitors

3Home

Reader #1 at time t2

Report card: Consistency C Performance B Availability B

2Visitors

5Home

Guarantee: See increasing subset of previous writes.

Page 14: Replicated Data  Consistency  in the Cloud

Read My Writesaka session guarantees

Under the covers:• update anywhere or

primary copy• client records

write-set• restrict reads to

sufficiently up-to-date replicas

home: 5home: 4

visitors: 2home: 3

visitors: 1home: 1

home: 2

Report card: Consistency C Performance C Availability C

2Visitors

5Home

Guarantee: See all writes performed by reader.

2Visitors

5Home

Scorekeeper

1Visitors

3Home

Other Reader

Page 15: Replicated Data  Consistency  in the Cloud

Consistency Trade-offs

Strong Consistency See all previous writes.

Eventual Consistency See subset of previous writes.

Consistent Prefix See initial sequence of writes.

Bounded Staleness See all “old” writes.

Monotonic Reads See increasing subset of writes.

Read My Writes See all writes performed by reader.

A D F

D A A

C B A

B C D

C B B

C C C

cons

isten

cype

rform

ance

avai

labi

lity

Page 16: Replicated Data  Consistency  in the Cloud

The Game of Baseball for inning = 1 .. 9 outs = 0; while outs < 3 visiting player bats; for each run scored score = Read (“visitors”); Write (“visitors”, score + 1); outs = 0; while outs < 3 home player bats; for each run scored score = Read (“home”); Write (“home”, score + 1); end game;

Page 17: Replicated Data  Consistency  in the Cloud

Official Scorekeeper

• Desired consistency?Strong= Read My Writes!

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

17

score = Read (“visitors”); Write (“visitors”, score + 1);

Page 18: Replicated Data  Consistency  in the Cloud

Umpire

• Desired consistency?Strong consistency

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

18

if middle of 9th inning then vScore = Read (“visitors”); hScore = Read (“home”); if vScore < hScore end game;

Page 19: Replicated Data  Consistency  in the Cloud

Radio Reporter

• Desired consistency?Consistent PrefixMonotonic Freshnessor Bounded Staleness

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

19

do { vScore = Read (“visitors”); hScore = Read (“home”); report vScore and hScore; sleep (30 minutes); }

Page 20: Replicated Data  Consistency  in the Cloud

Radio Reporter

• Desired consistency?Consistent PrefixMonotonic Freshness or Bounded Staleness

20

do { BeginTx(); vScore = Read (“visitors”); hScore = Read (“home”); EndTx(); report vScore and hScore; sleep (30 minutes); }

Use transaction to read from a consistent snapshot.

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

Page 21: Replicated Data  Consistency  in the Cloud

Sportswriter

• Desired consistency?Eventual?Strong = Bounded Staleness

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

21

While not end of game { drink beer; smoke cigar; } go out to dinner; vScore = Read (“visitors”); hScore = Read (“home”); write article;

Page 22: Replicated Data  Consistency  in the Cloud

Statistician

• Desired consistency?Strong Consistency (1st read)

Read My Writes (2nd read)

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

22

Wait for end of game; score = Read (“home”); stat = Read (“season-runs”); Write (“season-runs”, stat + score);

Page 23: Replicated Data  Consistency  in the Cloud

Stat Watcher

• Desired consistency?Eventual Consistency

Choices:• Strong• Eventual• Prefix• Bounded• Monotonic• Read My Writes

23

do { stat = Read (“season-runs”); discuss stats with friends; sleep (1 day); }

Page 24: Replicated Data  Consistency  in the Cloud

Summary of Baseball ParticipantsOfficial scorekeeper: score = Read (“visitors”); Write (“visitors”, score + 1);

Statistician: Wait for end of game; score = Read (“home”); stat = Read (“season-runs”); Write (“season-runs”, stat + score);

Umpire: if middle of 9th inning then vScore = Read (“visitors”); hScore = Read (“home”); if vScore < hScore end game;

Radio reporter: do { vScore = Read (“visitors”); hScore = Read (“home”); report vScore and hScore; sleep (30 minutes); }

Sportswriter: While not end of game { drink beer; smoke cigar; } go out to dinner; vScore = Read (“visitors”); hScore = Read (“home”); write article;

Strong ConsistencyStrong Consistency

Read My Writes

Consistent Prefix +

Monotonic Freshness

Bounded Staleness

Read My Writes

Stat watcher: stat = Read (“season-runs”); discuss stats with friends;

Eventual Consistency

Page 25: Replicated Data  Consistency  in the Cloud

Observations

• Different clients want different guarantees, even when accessing the same data

• All six consistency guarantees are useful• Clients (e.g. scorekeeper) may obtain strong

consistency with a weaker guarantee• Clients (e.g. radio reporter) may want multiple

guarantees for same read• Clients (e.g. statistician) may want different guarantees

for different reads• Strong consistency would be okay but result in worse

performance (and availability)

Page 26: Replicated Data  Consistency  in the Cloud

Consistency Average Read Time (ms)

strong 179

causal 48

bounded (30) 85

read-my-writes 28

monotonic 25

eventual 25

Read Performance

System: Pileus-on-AzureClient: laptop in Seattle running YCSBReplicas: West Europe (primary), North Europe, West US, East US

Page 27: Replicated Data  Consistency  in the Cloud

Conclusions

• Replication schemes involve tradeoffs between consistency, performance, and availability

• Applications may benefit from choices between strong and eventual consistency

• Choosing the best consistency requires understanding application semantics, usage scenarios, system properties, etc.