Consistency Model (Simplified)
Example:
-
Imagine row X is stored on two servers, M and N.
-
A user (Client A) updates row X on server M.
-
After some time, another user (Client B) reads row X from server N.
-
The consistency model determines if Client B will:
-
Definitely see the update,
-
Definitely not see it, or
-
Might or might not see it (uncertain).
-
Conflicting Operations
-
Read-Write Conflict: A read and a write happen at the same time.
-
Write-Write Conflict: Two writes happen at the same time.
Why Replicate Data?
-
Main reasons:
-
Reliability (backup copies)
-
Performance (faster access)
-
-
The downside:
-
Having many copies can lead to inconsistency if updates aren’t made to all of them.
-
-
To maintain consistency, all copies must be updated correctly and on time.
What is a Consistency Model?
-
It’s a set of rules that describe how memory should behave for programmers.
-
Helps match the programmer’s expectations with what the system actually does.
-
Acts like a contract:
-
If software follows certain rules, the memory system guarantees proper behavior.
-
-
It defines when and how memory changes become visible to processors in shared memory systems.
Consistency vs. Coherence
-
Coherence: Ensures all CPUs see writes to the same variable in the same order.
-
Consistency: Ensures all CPUs see writes to all variables in the right order.
Coherence (Think: One Variable at a Time)
Coherence means:
All CPUs must see changes to a single variable in the same order.
Example:
Imagine there's one whiteboard (a variable), and many people (CPUs) are watching it.
If someone writes on it:
-
Everyone should see the same order of changes — like “A, then B, then C” — not “B, then A” or “C, then B”.
So, coherence is about making sure everyone agrees on what happened and when — for one variable.
Consistency (Think: All Variables Together)
Consistency means:
All CPUs must see all changes across all variables in the correct order.
Example:
Now imagine there are multiple whiteboards (multiple variables).
If a person writes on whiteboard 1, then on whiteboard 2,
everyone else should see those changes in the same order — not mixed up.
So, consistency is about the overall story being the same for everyone — across all variables.
Two Ways to Define Consistency Models
-
Issue: What rules control when a process can perform operations.
-
View: What order of operations each process sees.
Types of Consistency Models
There are two main categories:
-
Data-Centric Consistency Models
-
Client-Centric Consistency Models
Common Consistency Models
-
Strict Consistency
-
Sequential Consistency
-
Causal Consistency
-
PRAM (or Processor) Consistency
-
Weak Consistency
-
Eventual Consistency
-
Release Consistency
Strict Consistency
-
The strongest model.
-
Any write is immediately visible to all processors.
-
Rule: A read always shows the most recent write.
-
Drawback: High communication cost due to many messages.
-
Limitation: Assumes no two writes can happen at the same time (which isn’t always true).
Sequential Consistency
-
Weaker than strict consistency.
-
Operations from all processors appear in some sequential order.
-
Simple and easier to understand.
-
Doesn’t guarantee best performance.
-
All actions must appear in a single, global sequence.
Sequential vs. Strict Consistency
-
Strict: Always shows the latest value.
-
Sequential: Shows operations in some order, not necessarily the latest.
Causal Consistency
-
Weaker than sequential consistency.
-
If one operation depends on another, all processors must see them in the same order.
-
If two operations are independent, they can be seen in different orders.
Weak Consistency
-
Doesn’t require every write to be seen immediately.
-
Synchronization points (like locks) ensure data consistency.
-
Before accessing data, all prior writes must be completed.
Eventual Consistency
-
Based on client-centric model.
-
Data updates are eventually reflected everywhere.
-
Common in systems with one writer and many readers (e.g., admin updates user database).
-
No write-write conflicts since only specific variable can update.
Client-Centric Consistency Models
1. Monotonic Reads
-
Once a process reads a value, future reads will show the same or newer value.
-
Useful for reading emails or calendar events across servers.
2. Monotonic Writes
-
A process’s writes happen in the correct order across all servers.
-
Ensures consistent file versions or software builds.
PRAM (Pipelined RAM) Consistency
-
Weaker model; focuses on write operations only.
-
Writes from the same processor are seen in order.
-
Writes from different processors can be seen in any order.
-
Also known as FIFO Consistency.
-
Simple and easy to implement.
Release Consistency
-
Improves on weak consistency.
-
Uses two synchronization operations:
-
Acquire: Enter critical section.
-
Release: Exit critical section.
-
-
updates are shared at synchronization points.
Comments
Post a Comment