Consistency and Replication55
Consistency and Replication55
Why Replicate?
Reliability:
• Creating copies of system parts (code and data) enhances reliability.
• If one copy fails, switch to another while fixing the issue.
Performance:
• Distribute requests across replicas to balance load.
• Improve response times by considering proximity of replicas to users.
Some notations
Read and write operations
• Wi (x )a: Process Pi writes value a to x
Possible behavior
We omit the index when possible and draw according to time (x-
axis):
Sequential consistency
Definition
• Operations by all processes were performed in a specific sequential
order.
• Operations for each process adhere to the order dictated by the program
itself.
Example
Three concurrent processes (initial values: 0)
Process P1 Process P2 Process P3
x ← 1; y ← 1; z ← 1;
p r i n t ( y, z ) ; print(x,z); print(x,y);
Grouping operations
Entry Consistency: a rule ensuring changes are complete before
others can access the data.
• Access to shared data is controlled by locks.
• Ensures operations are performed in order or sequence.
Write Operations:
• No lock access is permitted until all preceding write operations are
complete across all processes.
Read Operations:
• Ensures no data is accessed until all associated lock operations
have been executed.
Grouping operations
A valid event sequence for entry consistency
Observation
Entry consistency implies that we need to lock and unlock data.
Client-centric consistency:
• Ensures clients see updates in an orderly manner.
• Ideal for systems where data updates are not frequent or complex
to merge.
Eventual Consistency:
• Clients may see outdated data temporarily.
• Eventually or at the end, all clients will see the latest updates.
Example:
Social Media Feed:
• You post a photo on a social platform from your phone.
• Your friend might not see the photo immediately if they refresh
their feed from a computer.
• After a short delay, they refresh again and see the latest photo
you posted.
Monotonic reads
Consistency and replication Client-centric consistency models
Monotonic Writes:
Writes by a process are completed in the order they're made.
Example: If you update your contact list on your phone, that same
order of updates applies when you access it on your laptop.
Monotonic reads
Consistency and replication Replica management
Strategies:
• Minimize Client Distance: Choose locations closest to clients.
Computationally intensive.
• Autonomous System Approach: Place in largest systems' best-
connected hosts. High computational cost.
• Geometric Space Distribution: Identify nearest regions in a d-
dimensional space for placement based on latency and distance.
Computationally efficient.
Quorum-based protocols
Assume N replicas. Ensure that each operation is carried out in such a
way that a majority vote is established: distinguish read quorum NR and
write quorum NW . Ensure:
Caches at ISPs
Internet Service Providers also place caches to (1) reduce cross-ISP traffic
and (2) improve client-side performance. May get nasty when a request
needs to pass many ISPs.
Consistency and replication Example: Caching and replication in the Web
Cooperative caching
Consistency and replication Example: Caching and replication in the Web
Web-cache consistency
How to guarantee freshness?
To prevent that stale information is returned to a client:
• Option 1: let the cache contact the original server to see if content is
still up to date.
• Option 2: Assign an expiration time Texpire that depends on how long
ago the document was last modified when it is cached.
Consistency and replication Example: Caching and replication in the Web
Summary
• Client-centric consistency.