Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Replication as scaling technique (1) Replication as scaling technique (2)
2
Sequential Consistency Causal Consistency (1)
Sequential Consistency: • Necessary condition:
The result of any execution is the same as if – Writes that are potentially causally related must be
1. the operations by all processes on the data store were
seen by all processes in the same order.
executed in some sequential order and
2. the operations of each individual process appear in this – Concurrent writes may be seen in a different order
sequence in the order specified by its program on different machines. Causally related:
Possible valid sequence: concurrent R2(x)aW2(x)b
No single valid sequence W1(x)aW2(x)b
W2(x)b,R3(x)b,R4(x)b,W1(x)a, can be constructed
R3(x)a, R4(x)a
No process
may read R(x)b
and later R(x)a
a) A sequentially consistent data store. This sequence is allowed with a causally-consistent store,
b) A data store that is not sequentially consistent. but not with a sequentially consistent store.
3
Eventual Consistency Eventual Consistency
Replicas will converge
and gradually become
consistent
Update is performed at one replica
Propagation to other replicas is performed in a
lazy fashion
Eventually, all replicas will be updated
I.e., replicas gradually become consistent if no
updates take place for a long (enough) time
4
Read Your Writes Writes Follow Reads
A write operation is always completed before a successive Any successive write operation by a process on a data
read operation by the same process, no matter where the item x will be performed on a copy of x that is up to date
read operation takes place. with the value most recently read by that process.
Consistency of Replicas
When an object is replicated, the replicas must be
kept consistent according to some model
If there are no updates to the object, there is no Replication
consistency problem
If the “access to update” ratio is high, replication
should pay off
If the “update to access” ratio is high, many updates Basic concepts and consistency models
may be never accessed
Design considerations
Ideally, we should only update the replicas that are
going to be accessed Replication protocols (DS)
As a general rule, we try to keep a replica “close” to Replication in DB, SOA, P2P
its clients Replication and middleware
5
Basic design considerations Replica Placement (1)
Replica server placement
often a management or commercial issue
Replica (content) placement
Update propagation
state vs. operation
pull vs. push vs. lease
blocking vs. non-blocking
6
Update propagation Push (server)-based protocols
When there is an update, what is propagated Updates are propagated to other replicas
to the replicas? without those replicas asking for updates
Notification of changed parts of data (“invalidation”, Used by permanent and server-initiated
requires little bandwidth, good for small read-to- replicas, but also by some client caches
write ratio and large amount of data) High degree of consistency (consistent data
State transfer: Transfer the modified data (good for can be made available faster)
high read-to-write ratio); may transfer data, change If server keeps track of clients that have
logs, and/or aggregated cached the data, we have a “stateful” server:
Operation transfer: Propagate the update operation limited scalability and less fault tolerant
(“active replication”, uses little bandwidth if Often, multicasting is more efficient
parameter size is small, but requires more
processing power and determinism)
7
Hybrid: Lease Blocking vs. non-blocking
How long should a stateful server keep track of When are (push) updates propagated?
a client?
Leases dynamically switch push and pull
Synchronous (blocking):
A lease is a promise by the server to send All replicas are updated immediately, then
updates to the client cache (i.e. to push) for a
reply to client
fixed period of time
After expiry, client has to poll or request new Asynchronous (non-blocking):
lease (time can be adapted dynamically) Update is applied on one copy, then reply to
Types of leases with dynamic time: client, propagation to other replicas afterwards
age-based (e.g. Web): last time modified
renewal-frequency: popularity of data for client
state-space: server overload reduces lease time
Replication Protocols
Up to now: consistency models + general
design considerations
Replication
Implementation of the models? replication
protocols
Different protocols for different domains:
Basic concepts and consistency models
distributed object systems vs. databases vs.
Design considerations GRID vs. peer-to-peer systems (P2P) vs. SOA
Replication protocols (DS) Concepts, commonalities, differences?
Replication in DB, SOA, P2P
Replication and middleware
8
Replication Protocols DS Replication Protocols
What is replicated?
Classification: Where are updates initiated? Is there
a primary copy to which all write operations shall
“Traditional” Distributed Systems: objects, be forwarded?
processes
Database Systems: data (tables, rows)
Primary replica: Primary-based protocols
GRID: data (files, database)
Group of replicas: Replicated-write protocols:
P2P: files, typically read-only active replication, quorum based protocols
Service-oriented system: services, stateful (voting)
resources (data)
Disadvantages:
BACKUP
A write operation has to update all sites
1. Client initiates write operation at primary slow
2. Primary processes operation and propagates updates to backups
3. Backups apply update and reply to primary
not resilient against network or node failure
4. Primary replies to client
9
Chain replication Asynchronous Primary-backup
2. 4.
1. WRITE 3.
PRIMARY
CLIENT 1 3. 4.
BACKUP
BACKUP
10
Primary-Backup and Group Communication Coordinator cohort replication
Passive replication is asymmetric: Only one Only one replica receives request (coordinator)
replica actually processes the requests. However, coordinator may be different for different
Execution does not need to be deterministic. requests
The failure of the primary may not be
transparent to the clients. Advantages:
No central bottleneck
The choice of the primary, as well as the failure
and reintegration of the replicas has to be dealt No single point of failure
by the replication protocol.
Disadvantages:
The passive replication protocol is based on a
Updates need coordinated (distributed) concurrency
group membership service and on the view- control
synchronous multicast communication sync: distributed locking deadlocks can occur
primitive. async: inconsistencies reconciliation
(c) Rui Oliveira
11
Active (State Machine) Replication Active Replication (2)
replication-aware
communication layer
Advantages:
Assumption: Consistent replicas at begin
Simplicity (same code everywhere)
Determinism: when the same operations are
applied in the same order, all replicas will produce No bottleneck
the same result No single point of failure
Reasons for non-determinism: random(), time(),
multi-threading (thread scheduling unpredictable), Disadvantage:
transaction scheduling (concurrency control – Determinism required
timeouts for deadlock detection), ...
Ordering (consensus) more difficult
12
SMR and Group Communication SMR using atomic mutlicast
The failure of a replica tends to be transparent
for the clients.
The failure and reintegration of the replicas has
however to be dealt by the replication protocol.
The active replication protocol is based on a
communication primitive available to clients
that ensures the required order and atomicity
properties. This primitive is called total-order
multicast or atomic multicast
(c) Rui Oliveira (c) Oliveira, Wiesmann, Pedone, Schiper, Kemme, Alonso
13
Semi-Active Replication Quorum-Based Protocols
Write operations are performed on a write
quorum NW of replicas
Read operations are performed on a read
quorum NR of replicas
Two constraints must be obeyed:
NR + NW > N (R-W conflicts)
NW > N/2 (W-W conflicts)
Version numbers needed
Advantage: Determinism not required
“Majority voring”
Source: “Understanding Replication in Databases and Distributed Systems“ (Wiesmann, Pedone, Schiper, Kemme, Alonso; ICDCS 2000)
14
Gossip Protocols
Epidemic protocols with gossiping or “rumor
spreading” as propagation model
Replication
Analogous to real-life: P tries to push new
update to Q, as long as several others already
know, then it looses interest in spreading
Basic concepts and consistency models
Good way of rapidly spreading updates
Design considerations
However, some fraction of servers always
remains ignorant combining gossiping with Replication protocols (DS)
anti-entropy will do the trick Replication in DB, SOA, P2P
Replication and middleware
15
One-copy Serializability DB Replication Protocols
Primary-Backup (Primary-Copy):
“The effect of concurrent transactions on Conceptually equivalent to primary-backup replication
replicated data must be equivalent to the serial in DS (objects, processes, ...)
execution of the transactions on non-replicated Update Everywhere:
data.” Conceptually equivalent to coordinator-cohort
replication
Updates can be initiated at any replica
Correctness criterion for replicated databases
Advantages:
Similar to sequential consistency (no transactions Any site can run a transaction
in sequential consistency definition though) Load is evenly distributed
Disadvantages:
Copies need to be synchronized
Eager Lazy
Examples:
Update Update Atomic service: flight booking
Everywhere Everywhere Composite service: travel agency service combines
flight booking, hotel booking and car rental services
16
Stateless vs. Stateful Services Example for a Service-oriented System
Stateless service:
does not maintain state, e.g. file compression service
Stateful service:
Encapsulates state or persists it in an external stateful resource
(file, database), e.g. flight booking service
17
Replication in P2P systems P2P Replication Techniques
Distributed ownership lack of centralized Different terms used
control, no global knowledge (scale!) Active replication in P2P (~ push):
Cooperation between nodes is limited nodes A peer actively attempts to replicate a data item to
some other peer.
go offline anytime without informing peers
Concrete algorithms differ on
Node heterogeneity and link variations Number of replicas (e.g. uniform vs. proportional)
Mostly immutable data Location of replicas
18
Features of Replication Middleware Features of Replication Middleware (cont.)
1. Interception of client calls 2. Management of replicas
• Ideally, client should not need to care about • Middleware needs to know, where replicas are
replication. located.
• Client calls object as usual. • Middleware needs to know the roles of replicas
• Middleware intercepts the call and triggers (primary vs. backups).
replication logic. • Middleware should be able to change the role of
Invocation Service replicas (e.g., in case of the crash of a primary)
Replication Manager
19
Replication Middleware Architecture Summary
Replication helps to achieve better performance and
fault tolerance
Chosen replication protocol depends on different
Multicast Monitoring Replication Replication parameters: consistency requirements, read/write
Service Service Manager Protocol
ratio, number of clients, etc.
Most important protocols:
Primary-backup replication
Coordinator-cohort/Update-everywhere replication
Active replication
Transaction Service Invocation Service Quorum-based protocols
Need to be adopted for domain:
distributed object system, file system, database system,
service-oriented system, P2P system, etc.
20