0
0
HLDsystem_design~3 mins

Why Consistency models (strong, eventual) in HLD? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your app showed different data to different users at the same time--how confusing would that be?

The Scenario

Imagine you and your friends are editing a shared document by passing around a printed copy. Each person writes changes on their copy and then tries to update others by calling or texting. Sometimes, you see different versions of the document, and it's hard to know which one is the latest or correct.

The Problem

This manual way is slow and confusing. You waste time checking which version is newest. Mistakes happen because changes don't appear everywhere at once. You might overwrite someone else's work or work on outdated info. It's frustrating and error-prone.

The Solution

Consistency models like strong and eventual consistency help computers keep data in sync automatically. Strong consistency means everyone always sees the same latest data instantly, like a live shared screen. Eventual consistency means updates spread out over time, so data becomes the same eventually, like waiting for all friends to get the updated document.

Before vs After
Before
updateLocalCopy(); notifyFriends(); waitForReplies(); resolveConflictsManually();
After
writeToDatabase(); // system ensures data sync based on chosen consistency model
What It Enables

It enables systems to handle data updates smoothly and reliably, so users get correct information without confusion or delay.

Real Life Example

Online shopping sites use strong consistency for your payment info to avoid errors, but use eventual consistency for product reviews so they appear quickly even if not instantly synced everywhere.

Key Takeaways

Manual syncing of data is slow and error-prone.

Consistency models automate data synchronization with clear guarantees.

Choosing the right model balances speed and accuracy for better user experience.