In modern applications, data rarely lives in just one place. It's spread across multiple servers, potentially in different data centers around the globe.
This distribution brings scalability and resilience, but it also introduces a fascinating challenge: how do we ensure that all users, and all parts of the system, see a coherent and correct view of the data, especially when things are changing rapidly?
This is where consistency models come into play.
In this article, we’ll explore the different types of consistency models and when to choose them.
In a single-server system, consistency is straightforward. When data is updated, all subsequent reads see that new data. Simple.
But in a distributed system, when you write data to one node (replica), it takes time for that update to propagate to other nodes. During this propagation delay, different nodes might have different versions of the data.
Data Consistency Models define the rules and guarantees about the order and visibility of updates across replicas.
They provide a contract between the data store and the application:
Understanding these models is crucial because they directly impact: