Key Purpose Balance between consistency, availability, and performance (CAP theorem). A Consistency Model is a formal contract between a distributed system's data store and the processes accessing it. Balancing consistency, availability, and partition tolerance (CAP theorem).
Once a process reads a value, it will
Introduction to Consistency Models Key Challenges never see an older value. Synchronizing updates across geographically Email systems ensuring older emails Specifies how updates to replicas are seen across the system. distributed replicas. Example Monotonic Reads Focused on individual clients maintaining remain visible after syncs. Defines acceptable behavior for reads and writes. a consistent view of the data. Ensures writes by a single process are applied in order. (e.g., Amazon DynamoDB, Google Client-Centric Consistency Models Cloud databases Distributed version Spanner). Exampl Monotonic Writes control systems like Git Guarantees that a process sees Use Cases Distributed file systems (e.g., NFS, HDFS). its own updates in subsequent reads. Blogs immediately reflecting DNS systems, caching mechanisms, and collaborative tools Example Read-Your-Writes the author’s changes Ensures that writes following a read are applied to the most Provides a strong recent value Advantages guarantee of correctness. E-commerce platforms ensuring All reads return the result of the Example Writes-Follow-Reads most recent write, regardless of Impractical in large-scale distributed systems due to cart updates are consistent where the write occurred. synchronization overhead.
Strict Consistency Disadvantages Requires global clocks or perfectly synchronized systems.
Example Stock trading systems enforcing
Long-lived, stable replicas strict transaction ordering. Permanent Replicas in server clusters. All processes see operations in the Easier to implement than same order, but this order need not Advantages strict consistency Focused on maintaining a global view of Allows some level of asynchrony align with real-time. Created for performance the data store across replicas. improvement (e.g., CDN replicas). Server-Initiated Replicas Replica Types May lead to performance Sequential Consistency Disadvantages Data-Centric Consistency Models bottlenecks if writes are prioritized
Created temporarily based on client Example Shared memory systems ensuring
Replica Placement and Synchronization program order for threads. requests (e.g., browser caches). Client-Initiated Replicas (Models without Synchronization) Consistency Models in Distributed Systems These models define how the entire Notify replicas when data is outdated. Invalidation Protocols system behaves globally and ensure Extends sequential consistency by ensuring consistency of shared data Advantages Guarantees correct operation ordering real-time ordering of operations. Updates applied to all Synchronization Mechanisms Active Replication High performance cost due to replicas simultaneously. Linearizability (Atomic Consistency) Disadvantages real-time constraints Updates sent automatically by the server. Push Example: Banking systems ensuring debits Push/Pull Protocols occur before withdrawals. Clients request updates when needed. Pull Guarantees that causally related operations are seen in the same order by all processes. Operations not causally related may be Concurrent Operations observed in different orders. Causal Consistency Social media: Comments must appear Example after the post they reference.
Writes from a single process are
observed in order, but writes from Suitable for large-scale systems where Ensures all replicas eventually different processes may be seen in Advantages converge to the same state. varying orders. immediate consistency isn’t critical. Advantages Lightweight implementation. FIFO Consistency Eventual Consistency (PRAM Consistency) Temporary inconsistencies can occur Disadvantages Example Logs from distributed processes.
Uses synchronization variables
DNS resolving domain names. Example Ensures consistency only after explicit Mechanism to enforce consistency. synchronization operations. Weak Consistency Focused on relaxing consistency Example Parallel programming environments with Efficiently spread updates to all guarantees to improve shared memory replicas using minimal messages. performance and scalability. Acquire Ensures updates are visible Example Epidemic Protocols before accessing data Weak Consistency Models Uses acquire and release Definition operations for synchronization. Release Propagates changes upon Randomly synchronize exiting a critical region. (Models with Synchronization) Release Consistency updates between replicas. Advantages Provides better performance by separating synchronization from data access. Anti-Entropy Protocols Advanced Protocols Example Distributed file systems using locks for access control. Incrementally spread updates among replicas. Synchronization applies at the level of specific data items, not Advantages Efficient for localized critical sections. Gossip Protocols the entire data store. Entry Consistency Collaborative tools like Google Docs Example managing document sections