| Users | Strong Consistency | Eventual Consistency |
|---|---|---|
| 100 users | Single primary DB node; synchronous replication; low latency acceptable | Simple replication; minor delays in data sync; easy to maintain |
| 10,000 users | Primary with multiple synchronous replicas; increased write latency; network delays visible | Asynchronous replication; replicas may lag; better write throughput |
| 1,000,000 users | High write latency; complex coordination; risk of bottlenecks on primary node | Multiple data centers; replicas updated asynchronously; stale reads possible but acceptable |
| 100,000,000 users | Very high coordination overhead; write throughput limited; complex consensus protocols needed | Highly distributed; eventual convergence guaranteed; system favors availability and partition tolerance |
Consistency models (strong, eventual) in HLD - Scalability & System Analysis
For strong consistency, the first bottleneck is the write latency and coordination overhead on the primary database node. As user count grows, synchronous replication and consensus protocols slow down writes.
For eventual consistency, the bottleneck is data synchronization delays across replicas, which can cause stale reads but does not block writes.
- Strong Consistency: Use distributed consensus algorithms (e.g., Paxos, Raft) optimized for latency; scale vertically with powerful nodes; limit write contention by sharding data.
- Eventual Consistency: Use asynchronous replication; deploy data centers closer to users; implement conflict resolution strategies; use caching to serve stale but fast data.
- Hybrid approaches: Use strong consistency for critical data and eventual consistency for less critical data to balance performance and correctness.
Assuming 1 million users with 10 requests per second each:
- Total requests: 10 million QPS.
- Strong consistency DB can handle ~5,000 QPS per node; would need ~2,000 nodes or heavy sharding.
- Eventual consistency allows writes to be distributed; each node handles async replication; fewer nodes needed.
- Network bandwidth: 10 million QPS * 1 KB/request = ~10 GB/s; requires high bandwidth infrastructure.
- Storage: depends on data size and retention; replication increases storage needs by factor of replicas.
Start by defining the consistency models clearly. Then discuss trade-offs between latency, availability, and correctness. Use real-world examples like banking (strong consistency) vs social media feeds (eventual consistency). Finally, explain how scaling affects each model and what solutions you would apply.
Your database handles 1000 QPS with strong consistency. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Introduce read replicas to offload read traffic and implement sharding to distribute write load. Also, consider asynchronous replication if some delay is acceptable to improve write throughput.
Practice
strong consistency in distributed systems?Solution
Step 1: Understand strong consistency definition
Strong consistency means every read returns the most recent write, so all users see the same data instantly.Step 2: Compare options with definition
All users see the same data immediately after an update. matches this definition exactly, while others describe delayed or inconsistent views.Final Answer:
All users see the same data immediately after an update. -> Option AQuick Check:
Strong consistency = immediate data sync [OK]
- Confusing strong consistency with eventual consistency
- Thinking data can be permanently inconsistent
- Assuming delays are allowed in strong consistency
eventual consistency?Solution
Step 1: Recall eventual consistency meaning
Eventual consistency means updates may take time to reach all nodes, but eventually all nodes will have the same data.Step 2: Match options to definition
Data updates propagate over time and become consistent eventually. correctly states that data updates propagate over time and become consistent eventually.Final Answer:
Data updates propagate over time and become consistent eventually. -> Option DQuick Check:
Eventual consistency = delayed but eventual sync [OK]
- Assuming immediate synchronization in eventual consistency
- Confusing no synchronization with eventual consistency
- Thinking eventual consistency means permanent inconsistency
Solution
Step 1: Analyze eventual consistency update behavior
In eventual consistency, updates propagate asynchronously, so other nodes may temporarily have stale data.Step 2: Evaluate options against this behavior
Other nodes may temporarily show the old record until synchronization completes. correctly states that other nodes may show old data until synchronization finishes.Final Answer:
Other nodes may temporarily show the old record until synchronization completes. -> Option AQuick Check:
Eventual consistency = temporary stale reads [OK]
- Expecting instant update on all nodes
- Confusing update rejection with consistency model
- Assuming data deletion on other nodes
Solution
Step 1: Understand strong consistency guarantees
Strong consistency guarantees all users see the latest data immediately after update.Step 2: Analyze why outdated data appears
If users see outdated data, the system likely does not enforce strong consistency, possibly using eventual consistency instead.Final Answer:
The system is actually using eventual consistency under the hood. -> Option BQuick Check:
Outdated data means no strong consistency [OK]
- Blaming network speed for outdated data
- Assuming user refresh frequency causes inconsistency
- Confusing synchronous replication with eventual consistency
Solution
Step 1: Identify critical data requirements
Inventory stock count must be accurate to prevent overselling, requiring immediate data correctness.Step 2: Choose consistency model based on requirements
Strong consistency ensures all users see the latest stock count instantly, preventing overselling.Final Answer:
Strong consistency, because it guarantees all users see the latest stock count immediately. -> Option CQuick Check:
Critical data needs strong consistency [OK]
- Choosing eventual consistency for critical stock data
- Ignoring consistency needs for inventory
- Assuming no consistency is acceptable
Ready to prove it?
Pass the test and this pattern moves unknown
