Distributed Systems

Consistency Models in Distributed Systems

Consistency Models: Practical Examples

1. Linearizability (Strong Consistency)

Banking Example: You withdraw $200 from an ATM. Your spouse checks the balance at another ATM immediately after and sees the updated amount.

2. Sequential Consistency

Document Editing Example: Alice adds paragraph A, Bob adds paragraph B. All users see both paragraphs in the same order (either A→B or B→A), but not necessarily matching real-time order.

3. Causal Consistency

Social Media Example: Post → Comment → Reply always appear in that order to all users, but unrelated posts may appear in different orders.

4. Session Guarantees

5. Eventual Consistency

DNS Example: Change your website’s IP address. Some users get the new address immediately, others temporarily get the old one, but eventually all see the new address.

6. Conflict Resolution Approaches

Calendar Example: You and a colleague both schedule different meetings at 2 PM while offline. When reconnecting, the system must resolve this conflict.

The right consistency model depends on your application’s requirements around correctness, availability, and performance. Stronger consistency typically means higher latency and reduced availability during network partitions.