31
06/15/22 Distributed Systems - Comp 655 1 Consistency and Replication • The problems we are trying to solve • Types of consistency • Approaches to propagation

12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

Embed Size (px)

Citation preview

Page 1: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 1

Consistency and Replication

• The problems we are trying to solve

• Types of consistency• Approaches to propagation

Page 2: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 2

Transparency in a Distributed System

Transparency Description

AccessHide differences in data representation and how a resource is accessed

Location Hide where a resource is located

Migration Hide that a resource may move to another location

RelocationHide that a resource may be moved to another location while in use

Replication Hide that a resource is replicated

ConcurrencyHide that a resource may be shared by several competitive users

Failure Hide the failure and recovery of a resource

Page 3: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 3

What problems does replication solve?

• Some capacity and performance problems– Keep replicas on both sides of a bottleneck– Keep replicas on both sides of a connection

with long delays

• Two kinds of incoherence:– Replication provides some location

transparency– Replication provides some failure transparency

(aka fault tolerance)Continue to work if one copy goes downContinue to work if the network goes down

Page 4: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 4

What problems does replication cause?

• Consistency– To maintain concurrency

transparency, system has to keep replicas updated

• Complexity – To maintain replication transparency,

system has to be able to locate and select appropriate replicas

• Overhead can take back capacity and performance gains

Page 5: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 5

If you remember onlyone two thing(s) …

1. There are many types of consistency, known as “consistency models”

2. As the consistency model gets stronger

• The system gets easier to use.• The system gets harder to

implement.• The system gets slower and

consumes more resources.

Page 6: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 6

Consistency and Replication

• The problems we are trying to solve

• Types of consistency• Approaches to propagation

Page 7: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 7

Types of (data-centric) consistency

Page 8: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 8

Ground rules for examples• Examples deal with a company’s inventory

data• Inventory data is replicated at every

location• This is for illustrative purposes; we are NOT

claiming this is a good architectural idea• Assume each process in each example is at

a different location• Assume that invisible processes propagate

each update to all other copies• Time moves left to right

Page 9: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 9

Strict consistency

P1:

P2:

P1:

P2:

D=H

D:DVD players, H:high, L:low, set:=, get:?

D?H

D=H

D?L D?H

Yes

No

Page 10: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 10

Sequential consistency 1

P1:

P2:

P3:

P4:

D=H

D=L

D?L

D?L D?L

D?L

D:DVD players, H:high, L:low, set:=, get:?

Page 11: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 11

Sequential consistency 2

P1:

P2:

P3:

P4:

D=H

D=L

D?L

D?L D?H

D?H

D:DVD players, H:high, L:low, set:=, get:?

Page 12: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 12

Sequential consistency - not

P1:

P2:

P3:

P4:

D=H

D=L

D?L

D?H D?L

D?H

D:DVD players, H:high, L:low, set:=, get:?

Page 13: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 13

Cost of sequential consistency

• Assume we have a distributed system with a replicated store and a feature to maintain consistency across the replicas

• Let r be the expected read time• Let w be the expected write time• Let t be the minimal packet transfer

time between nodes in the system• Then r + w t

Page 14: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 14

Causal consistency

P1:

P2:

P3:

P4:

D=L

D?L

D?L

D?HD?L

D?H

D=M

D=H

D?M

D?M

No causal relationship

Not sequentially consistent

Potential causal relationships

D:DVD players, H:high, M: medium, L:low, set:=, get:?

Page 15: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 15

Causal consistency - not

P1:

P2:

P3:

P4:

D=L

D?L

D?H

D?H

D=H

D?L

D?L

Potential causal relationship

D:DVD players, H:high, L:low, set:=, get:?

Page 16: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 16

Causal consistency - ok

P1:

P2:

P3:

P4:

D=L

D?M

D?M

D=M

D?L

D?L

No causal relationship

D:DVD players, M:medium, L:low, set:=, get:?

Page 17: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 17

Types of (data-centric) consistency

Page 18: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 18

Eventual consistency• DNS

– A domain can only be updated by its naming authority (therefore, no write-write conflicts)

– Updates propagated on a schedule– Most accesses work from cache– Can refresh a cached value on failure

• Web– A page can only be updated by its owner

(again, no write-write conflicts)– Most accesses work from cache– Page can be refreshed if user suspects a

failure

Page 19: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 19

Client-centric consistency

Page 20: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 20

Client-centric consistency models

Model The ideaMonotonic reads

Each read by a process returns the same value as the previous read, or a more recent value

Monotonic writes

Each write by a process must complete before the next write of the data item by the process

Read your writes

Each write by a process will be visible in any subsequent read by that process

Writes follow reads

Each write by a process after a read will be done at all replicas on a value that is at least as recent as the value read

Page 21: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 21

Client-centric examples• Imagine a discussion group with

replicas in Columbus and Nairobi• Imagine these events

– Alice starts thread A– Bob starts thread B– Alice edits A to make A’– Alice adds attachment to make A’’– Carol posts reply AC

Page 22: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 22

Monotonic reads

Columbus Nairobi

Carol reads againOK

B

A A

Carol reads

BNot mono read

Page 23: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 23

Monotonic reads

Columbus Nairobi

Carol reads againOK

A

A B

Carol reads

BNot mono read

Page 24: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 24

Monotonic writes

Columbus Nairobi

OK

A’

A A

A’’

A’Not mono write

Page 25: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 25

Read your writes

Columbus Nairobi

Alice reads againOK

A

A B

AC

BNot read your writes

Alice reads

AC

Read your writes, butNon-monotonic reads

Page 26: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 26

Writes follow reads

Columbus Nairobi

AC arrivesOK

A

A

Carol reads

AC

Not writes follow reads

Page 27: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 27

Writes follow reads to prevent this

Columbus Nairobi

A

AC

A

Carol reads

AC

Bob reads Dave readsDave sees replybefore original

Page 28: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 28

Consistency and Replication

• The problems we are trying to solve

• Types of consistency• Approaches to propagation

Page 29: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 29

Types of replicas

Any experience with server-initiated replicas?

Page 30: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 30

What to propagate?• Notifications• Updated data• Update operations

Page 31: 12/17/2015Distributed Systems - Comp 6551 Consistency and Replication The problems we are trying to solve Types of consistency Approaches to propagation

04/21/23 Distributed Systems - Comp 655 31

Who initiates propagation?• Server (push-based protocol)• Client (pull-based protocol)