Consistency Models in Distributed Systems

When your data is stored on many computers (servers) instead of one, we need to make sure that everyone sees the same data — even if they’re asking different servers.

A consistency model is like a rulebook. It says:

“If one person changes something, when and how should others see it?”

Let’s look at the main types.


1. Strong Consistency

What happens:
Everyone always sees the latest update — instantly.

Example:
You change your phone number in a system. Anyone who checks it after that will see the new number, no matter which server they ask.

Best for:
Bank apps, payment systems — where the correct value is very important.

Downside:
It can be slow, because all servers must agree before giving answers.


2. Sequential Consistency

What happens:
Everyone sees things in the same order, but maybe not right away.

Example:
You first change your name, then your address. Others might see both changes later, but they’ll always see the name change before the address change.

Best for:
Systems where the order of actions matters, like event logs.


3. Causal Consistency

What happens:
If one thing depends on another, people always see them in the right order.

Example:
You post a photo, then someone comments on it. Everyone will see the photo before they see the comment.

Best for:
Social media, chat apps — where replies must make sense.

Note:
If two actions don’t depend on each other, they might appear in different orders for different people.


4. Eventual Consistency

What happens:
Everyone will see the right data — just not right away.

Example:
You change your address. It shows up immediately on your phone, but your laptop still shows the old one. After a few seconds, the laptop catches up.

Best for:
Big systems like Amazon or Gmail. Some delay is okay.

Downside:
People may briefly see wrong or old data.


5. Weak Consistency

What happens:
There are no rules. Sometimes you’ll see the update, sometimes not.

Example:
You upload a photo, but sometimes it doesn’t show up — or it disappears and reappears.

Best for:
Temporary storage or low-priority data where correctness isn’t important.


Summary Table

Consistency Model What It Feels Like Best For
Strong Everyone sees the latest data immediately Banking, transactions
Sequential Everyone sees changes in the same order Logs, order-sensitive systems
Causal Replies always come after original messages Social apps, chat
Eventual Everyone gets the correct data, eventually Large websites, online stores
Weak Anything can happen Caches, non-important data

Final Words

Think of these models like different levels of “how much can I trust the data I’m seeing?”

  • If you need perfect accuracy, choose strong consistency.
  • If you need speed and flexibility, eventual or causal consistency is usually good enough.

Leave a Comment