Consistency models define how updates are seen across nodes in a distributed system. The CAP theorem highlights a trade-off between Consistency, Availability, and Partition Tolerance. A system can guarantee at most two of these properties.
Strong Consistency
Strong consistency ensures all nodes reflect the latest write. Operations appear globally ordered, and every read returns the most recent write. The strongest form of strong consistency is Linearizability, which additionally requires that the ordering respects real-time — if operation A completes before operation B starts, A must appear first. Systems like Google Spanner prioritize correctness, making it suitable for financial or critical transactional systems.
Eventual Consistency
Eventual consistency guarantees replicas converge over time. Writes are faster since updates propagate asynchronously. Temporary inconsistencies are acceptable. Systems like DynamoDB and Cassandra prioritize availability and resolve conflicts using strategies like last-write-wins.
Causal Consistency
Causal consistency orders operations with causal dependencies while allowing unrelated operations to appear in different orders. It is implemented in systems needing logical dependencies, like collaborative editing. Techniques like vector clocks capture these relationships.
Read-After-Write Consistency
This ensures a client always sees its writes within a session. Other clients may observe stale data. It is commonly used in user-specific scenarios like social media timelines.
Bounded Staleness
Bounded staleness ensures data is no older than a predefined time or version. It is a middle ground between strong and eventual consistency, used in analytics platforms or CDNs where small delays are acceptable.