Sequential Consistency Model and Linearizability Model in Distributed System(Base Models).Sequential Consistency Model In Distributed System Consistency Models In Distributed Systems Causal Consistency In Distributed System Consistency Models In Distributed Systems Video Lecture. Implementing Sequential Consistency Model Linearizability Vs. Sequential Consistency Examples Distributed Systems Replication And Consistency Distributed Systems.
Contents
- 0.0.1 Sequential Consistency and Linearizability in Distributed Systems
- 0.0.2 What is Sequential Consistency?
- 0.0.3 Definition
- 0.0.4 Example of Sequential Consistency
- 0.0.5 What is Linearizability?
- 0.0.6 Definition
- 0.0.7 Example of Linearizability
- 0.0.8 Difference Between Sequential Consistency and Linearizability
- 0.0.9 Real-World Use Cases
- 0.0.10 Summary
- 1 Consistency Models in Distributed Systems
Sequential Consistency and Linearizability in Distributed Systems
In distributed systems, maintaining consistency is a crucial challenge. Two important consistency models used to define how operations should be executed and observed are Sequential Consistency and Linearizability. These models help in designing reliable and predictable systems, ensuring correct execution of concurrent operations.
What is Sequential Consistency?
Definition
Sequential Consistency ensures that the result of execution is as if all operations were executed in some sequential order, and each process sees operations in the same order. However, it does not guarantee real-time execution order.
Key Property:
Operations from different processes may be interleaved, but they must respect the program order within each process.
Example of Sequential Consistency
Consider two processes (P1
and P2
) updating a shared variable X
, initially set to 0
.
Operations:
P1: X = 1
P2: print(X)
(can see X = 0
or X = 1
, depending on execution order)
Possible Sequentially Consistent Execution Orders:
Order 1: P1 → P2
→ (P2 sees X = 1
)
Order 2: P2 → P1
→ (P2 sees X = 0
)
Even though execution may not match real-time order, all processes see changes in a consistent sequence.
What is Linearizability?
Definition
Linearizability (Atomic Consistency) is a stronger consistency model than Sequential Consistency. It ensures that each operation appears to take effect instantaneously at some point between its start and end time.
Key Property:
All operations must appear to execute in a real-time order. If operation A
completes before operation B
starts, then A
must be observed before B
.
Example of Linearizability
Consider the same shared variable X
with processes P1
and P2
.
Operations:
P1: X = 1
P2: print(X)
If P2
starts reading after P1
has updated X
, P2 must see X = 1
.
Linearizability ensures that no process ever sees an outdated value after an update.
Difference Between Sequential Consistency and Linearizability
Feature | Sequential Consistency | Linearizability |
---|---|---|
Ordering | Preserves execution order but allows reordering across processes | Preserves both execution order and real-time constraints |
Real-Time Guarantee | No | Yes |
Use Case | Useful in systems where exact real-time order is not required | Required in financial transactions, database consistency, and real-time systems |
Performance | Better performance as it allows reordering | Expensive as it requires strict order maintenance |
Real-World Use Cases
Sequential Consistency:
Cloud Storage (Amazon S3, Google Drive) – Ensures eventual order but does not guarantee real-time updates.
Distributed Caching – Helps in optimizing performance by allowing relaxed ordering.
Linearizability:
Bank Transactions (Atomicity in Databases) – Ensures that withdrawals and deposits reflect in real-time.
Leader Election (Raft, Paxos) – Ensures strict order in distributed consensus.
Summary
Sequential Consistency ensures operations appear in some global sequence, but real-time execution may be violated.
Linearizability is a stronger guarantee where operations must appear instantaneous and respect real-time order.
Linearizability is expensive but necessary for critical systems like banking and distributed databases.
Which consistency model do you think is more suitable for real-world distributed systems?
Here’s a detailed and clear comparison of the Sequential Consistency Model and the Linearizability Model in distributed systems — two important consistency models used to reason about the behavior of concurrent systems like databases, caches, and shared memory.
Consistency Models in Distributed Systems
In distributed systems, consistency models define the rules for the visibility and ordering of read/write operations across multiple nodes or processes.
The two commonly discussed models are:
1. Sequential Consistency Model
Definition:
A system is sequentially consistent if the result of execution is the same as if:
-
All operations were executed in some sequential order
-
The order of operations of each individual process is preserved
Example:
Let’s say two processes perform the following writes:
Then any sequential consistency-compliant system might produce:
-
P1 sees: 1, then 2
-
P2 sees: 1, then 2
OR -
Both see: 2, then 1
BUT NOT -
P1 sees: 1, 2
P2 sees: 2, 1 (violates process order)
Key Properties:
-
Preserves program order per process
-
Doesn’t require a real-time order between operations
2. Linearizability (Atomic Consistency) Model
Definition:
A system is linearizable if:
-
The result is as if operations occurred in some global sequential order
-
AND this order respects real-time — if operation A completes before B starts, then A appears before B
Example:
Let:
-
P1: write(x = 1) finishes at time T1
-
P2: write(x = 2) starts at time T2 > T1
Then all processes must see x = 2 after time T2, not x = 1.
Key Properties:
-
Stronger than sequential consistency
-
Matches real-world intuition of time and operation visibility
-
Guarantees immediate visibility
Sequential Consistency vs Linearizability
Feature | Sequential Consistency | Linearizability |
---|---|---|
Operation Order | Preserves per-process order | Preserves real-time order |
Global View | Appears as one sequence | Appears as one sequence with real-time constraint |
Strength | Weaker than linearizability | Stronger |
Performance | More scalable | Less scalable (requires stricter coordination) |
Example Use | CPU memory models, shared variables | Distributed databases, locks, registers |
Analogy
-
Sequential Consistency: Everyone agrees on what happened, but not exactly when. -
Linearizability: Everyone agrees on what and when it happened, respecting real-world time.
Conclusion
-
Sequential Consistency: Suitable when timing doesn’t matter, but order does.
-
Linearizability: Used when strong guarantees are needed (e.g., banking systems, locks, atomic registers).
Would you like this as:
-
A presentation? -
Lecture notes or handout? -
Example code to simulate consistency in Python?
Let me know!