Eventual Consistency

EVENTUAL - Understanding the Relaxed Model

๐ŸŒŠ Master eventual consistency, convergence, and when to use it safely in production!

๐Ÿ“– Twitter: When Eventual Consistency Powers Billions

Twitter (X) processes 500 million tweets per day with billions of timeline loads. The secret? Eventual consistency! Challenge: If they used strong consistency (QUORUM) for every timeline update = impossible to scale. Latency would be 50-100ms per operation, throughput limited to thousands/sec. Problem: Users scroll timelines millions of times per second! Need sub-5ms response, infinite scale. Twitter's solution: Eventual consistency (ONE + ONE) for timeline updates! The trade-off: Tweet might not appear immediately in your timeline. You refresh โ†’ it appears! Users expect this behavior - nobody expects real-time perfect timelines. Result: 3-5ms timeline loads, 100,000+ reads/sec per node, billions of timeline updates/day, eventual convergence within seconds. The insight: Not all data needs strong consistency! Timelines, like counts, feeds = eventual is perfect. Tweets themselves, user accounts = strong consistency (QUORUM). Twitter Engineering: "Eventual consistency lets us scale to billions. The key is knowing WHEN to use it and HOW to handle the convergence delay!"

๐Ÿ’ป Interactive Eventual Consistency Simulator

See eventual consistency in action! Watch data converge over time!

cqlsh@eventual-cluster

๐ŸŒŠ Eventual Scenarios - Click to Explore:

๐ŸŒŠ Eventual Consistency Simulator Ready!
โฐ Click scenarios above to see convergence patterns
โœ“ Learn when eventual consistency is safe and when it's dangerous

๐ŸŒŠ The Eventual Promise

Eventual consistency means: If no new updates are made, all replicas will EVENTUALLY converge to the same value. You trade immediate consistency for massive scalability! Twitter, Facebook, Instagram all rely on eventual consistency for billions of operations per day. The key is understanding the convergence window (typically 20-100ms) and knowing which data can tolerate it!

๐ŸŒŠ What is Eventual Consistency?

Imagine you have three water tanks connected by pipes. You pour water into Tank A. The water doesn't instantly appear in Tanks B and C - it flows through the pipes and eventually all tanks reach the same level. That's eventual consistency! You trade immediate synchronization for speed. Tank A responds instantly, but Tanks B and C catch up within seconds.

๐Ÿ’ง The Water Tank Analogy

You have 3 water tanks in different cities: New York, London, Tokyo. They're connected by pipes.

With Strong Consistency (QUORUM):
โ€ข You pour 10 gallons into NY tank
โ€ข You must wait until water flows to London AND Tokyo
โ€ข Only after majority (2/3) tanks have 10 gallons โ†’ SUCCESS
โ€ข Takes 150ms (water flows across ocean!)
โ€ข Slow but guaranteed!

With Eventual Consistency (ONE):
โ€ข You pour 10 gallons into NY tank
โ€ข NY tank immediately says "Got it!" (3ms)
โ€ข You're done! Walk away.
โ€ข Water flows to London and Tokyo in background (20-50ms)
โ€ข Eventually all 3 tanks at same level โœ“

The trade-off:
If someone checks London tank immediately after your pour, they might see 0 gallons (stale!). But within seconds, all tanks match. For water tanks that don't need instant sync โ†’ eventual is 50x faster!

Cassandra is the same: Write to one replica (fast!), others catch up in background (eventual).

โšก

Speed Priority

Behavior: Write succeeds immediately (3-5ms)
Replicas: ONE confirms, others update async
Throughput: 50,000+ operations/sec
Use case: Timelines, counters, analytics
Trade-off: Reads might be stale for 20-100ms
Benefit: Massive scalability!

โฐ

Convergence Guarantee

Promise: If no new writes, all replicas converge
Window: Typically 20-100ms for convergence
Mechanism: Background replication + read repair
Result: Eventually consistent (hence the name!)
Reality: "Eventually" = seconds, not hours
Math: R + W โ‰ค RF (no overlap guarantee)

๐Ÿ“Š

CAP Theorem Choice

CAP: Consistency, Availability, Partition Tolerance
Pick 2: Can't have all 3 simultaneously
Eventual: Prioritizes AP (Availability + Partition)
Strong: Prioritizes CP (Consistency + Partition)
Trade-off: Eventual sacrifices C for better A
Benefit: System always responds!

๐Ÿ’ก Key Insight: The Convergence Promise

Eventual consistency means: "If you stop writing, all replicas will eventually agree." It's not "maybe consistent" or "random consistency" - it's a mathematical guarantee! The "eventual" part is typically 20-100ms in production, not minutes or hours. Twitter, Facebook, Instagram all rely on this for billions of operations daily. The key is understanding which data can tolerate the convergence window!

โฐ How Eventual Consistency Works

Eventual Consistency: Convergence Timeline (RF=3, CL=ONE) T=0ms: Write "email=new@example.com" with CL=ONE Replica A new@... โœ“ ACK (3ms) Replica B old@... (stale!) Replica C old@... (stale!) T=5ms: Read with CL=ONE โ†’ Coordinator picks Replica B Replica A new@... Replica B old@... โ† READ HERE! Replica C old@... Returns: old@... STALE! โŒ T=20ms: Background Replication โ†’ Replica B Updated Replica A new@... Replica B new@... โœ“ Updated! Replica C old@... (still stale) T=50ms: CONVERGENCE COMPLETE! All Replicas Consistent โœ“ Replica A new@... Replica B new@... Replica C new@... Future reads: Always new@... โœ“ Convergence Window: 50ms (typical: 20-100ms) | Stale Read Risk: 66% during window | Eventually Consistent: Guaranteed!

โฐ Understanding the Timeline

The convergence process: Write hits Replica A in 3ms โ†’ Client gets SUCCESS immediately! Replicas B and C update in the background (20-50ms). During this window, reads have a 66% chance (2/3) of hitting a stale replica. After ~50ms, all replicas converged โ†’ consistent forever (until next write). This is why eventual consistency is so fast - you don't wait for replication!

๐Ÿ”„ Convergence Deep-Dive

Convergence is the process by which all replicas eventually agree on the same value. It's not magic - it's a well-defined process with predictable timelines!

1๏ธโƒฃ

Background Replication

Mechanism: Async replication after write ACK
Process: Coordinator sends to all replicas in parallel
ONE: Waits for 1 ACK, others continue in background
Timing: Background writes complete in 20-50ms
Network: Depends on network latency between nodes
Guarantee: Eventually all replicas get the data

2๏ธโƒฃ

Read Repair

Mechanism: Fix inconsistencies during reads
Process: Coordinator queries multiple replicas
Detection: Notices different values returned
Action: Returns latest, updates stale in background
Timing: Immediate (piggybacks on read)
Benefit: Accelerates convergence passively

3๏ธโƒฃ

Hinted Handoff

Mechanism: Handle temporarily down nodes
Process: Coordinator stores "hint" if node down
Storage: Hint saved locally by coordinator
Replay: When node recovers, hints replayed
Timing: Can be hours if node down long
Guarantee: Data eventually reaches destination

4๏ธโƒฃ

Anti-Entropy Repair

Mechanism: Proactive consistency checking
Process: Merkle tree comparison between nodes
Schedule: Runs automatically (nodetool repair)
Detection: Finds divergences in data
Repair: Syncs inconsistent data
Frequency: Weekly recommended in production

โฑ๏ธ

Convergence Windows

Typical: 20-100ms in production
Same DC: 20-50ms (fast!)
Cross DC: 100-300ms (network latency)
Factors: Network speed, cluster size, load
Monitoring: Track with nodetool tpstats
SLA: Usually measured in milliseconds, not seconds

๐Ÿ“Š

Factors Affecting Speed

Network latency: Biggest factor (msโ†’datacenter)
Cluster load: Busy nodes = slower replication
Replication factor: More replicas = more work
Data size: Larger writes = longer transfer
Compression: Can help with large values
Tuning: Network buffers, batch sizes

๐Ÿ“ˆ Real Production Convergence Example

Facebook Likes: When you like a post, it's written with CL=ONE:

T=0ms: You click like โ†’ Write to US-East replica โ†’ SUCCESS (3ms)
T=5ms: Friend in Europe views post โ†’ Reads from EU replica โ†’ Shows old count (stale!)
T=25ms: Background replication โ†’ EU replica updated โ†’ Now shows your like โœ“
T=150ms: Asia replica updated โ†’ Global convergence โœ“

Why this works: Nobody expects instant-perfect like counts! "12.3k likes" vs "12.3k+1" doesn't matter. The 25-150ms convergence window is completely acceptable for social media engagement metrics. Facebook handles billions of likes per day with this model!

โš ๏ธ Conflict Resolution: Last-Write-Wins

When two writes happen concurrently to the same key, Cassandra needs a way to resolve the conflict. The answer: Last-Write-Wins (LWW) based on timestamps!

๐Ÿ•

The Problem

Scenario: Two users update same row simultaneously
User A: Writes "email=alice@a.com" at T=1000
User B: Writes "email=bob@b.com" at T=1001
Conflict: Which email should win?
Issue: Both got SUCCESS from CL=ONE
Result: Replicas have different values!

โฑ๏ธ

Last-Write-Wins

Mechanism: Compare timestamps, latest wins
T=1000: alice@a.com (earlier timestamp)
T=1001: bob@b.com (later timestamp)
Winner: bob@b.com (1001 > 1000)
Loser: alice@a.com silently discarded โŒ
Result: All replicas converge to bob@b.com

โš ๏ธ

Silent Data Loss

User A writes: Gets SUCCESS โœ“
User B writes: Gets SUCCESS โœ“ (concurrent)
Convergence: B's write wins (later timestamp)
User A's data: Silently discarded โŒ
No error: Both users think write succeeded!
Reality: A's write disappeared

๐Ÿšจ Clock Skew Problem

Critical issue: LWW depends on server clocks being synchronized! If Server A's clock is 1 second ahead of Server B, ALL writes from Server A will win - even if Server B wrote "first" from a human perspective! This is why NTP (Network Time Protocol) is critical in Cassandra clusters. Clock skew > 100ms can cause serious data corruption. Always monitor clock drift!

๐Ÿ›’ Shopping Cart Disaster

Real bug from production e-commerce site:

User adds iPhone to cart โ†’ SUCCESS (timestamp: 1000)
2 seconds later, user adds MacBook โ†’ SUCCESS (timestamp: 1001)

But both writes were concurrent due to network delay! Convergence:

  • Replicas compare timestamps
  • MacBook write (1001) > iPhone write (1000)
  • Result: cart = [MacBook]
  • iPhone disappeared! โŒ
User goes to checkout โ†’ "Where's my iPhone?!"

Fix: Use QUORUM instead of ONE, or use append-only model (each item separate row, never UPDATE)!

โœ… Safe Use Cases for Eventual Consistency

Eventual consistency is perfect for certain types of data where speed matters more than instant accuracy!

๐Ÿ“ฐ

Social Media Timelines

Examples: Twitter feed, Instagram timeline, Facebook news feed
CL: ONE for writes and reads
Why Safe: Users expect refresh to see updates
Staleness: "Missing tweet briefly" = expected behavior
Volume: Billions of timeline loads/day
Performance: Need sub-5ms for good UX
User Tolerance: Very high - they refresh constantly!

๐Ÿ‘

Like/Reaction Counters

Examples: Facebook likes, Instagram hearts, Twitter retweets
CL: ONE for incrementing counters
Why Safe: Approximate counts perfectly fine
Staleness: "12.3k vs 12.4k" immaterial
Volume: Billions of likes per day
Performance: Must be instant (2-3ms)
User Tolerance: Complete - rounded numbers anyway!

๐Ÿ“Š

Analytics & Metrics

Examples: Pageviews, click tracking, event logging
CL: ONE for high-volume writes
Why Safe: Aggregates computed in batch anyway
Staleness: Report shows "523 vs 524 views" = no impact
Volume: Millions of events per minute
Performance: Cannot block application flow
User Tolerance: High - analytics are approximate

๐Ÿ”

Search Results Cache

Examples: Google search cache, product search results
CL: ONE for cache writes/reads
Why Safe: It's a cache! Stale = re-fetch
Staleness: Missing result โ†’ next search finds it
Volume: Billions of cache operations
Performance: Speed critical for search UX
User Tolerance: Very high - expected cache behavior

๐Ÿ’ฌ

Chat Read Receipts

Examples: WhatsApp blue checkmarks, Slack "seen" status
CL: ONE for status updates
Why Safe: Delay of seconds acceptable
Staleness: "Seen" appears 2-5 seconds late = OK
Volume: Billions of receipt updates
Performance: Must not slow message delivery
User Tolerance: High - not time-critical

๐Ÿ“

Activity Logs

Examples: User activity feed, audit logs (non-compliance)
CL: ONE for log writes
Why Safe: Logs are append-only, order less critical
Staleness: Log appears 1-2 seconds later = acceptable
Volume: Massive - millions per second
Performance: Cannot impact application performance
User Tolerance: Complete - batch processing anyway

โœ… Common Thread: Non-Critical, High-Volume

Notice the pattern? Safe use cases share these traits: (1) High volume that demands speed, (2) Approximate/eventual data is acceptable, (3) Non-critical to business operations, (4) Regenerable or append-only, (5) Users expect delayed updates. If your data matches these criteria โ†’ eventual consistency is perfect!

โŒ Danger Zones: When Eventual is Wrong

Some data types are dangerous with eventual consistency. Using ONE here causes serious problems!

๐Ÿ‘ค

User Profiles

Data: Email, password, bio, settings
Problem: User updates email โ†’ refreshes โ†’ sees OLD
Impact: "Did my update save?!" panic
Risk: Ghost data - flip-flopping old/new
Concurrent: Two updates = one lost (LWW)
User Tolerance: Zero - expect immediate
Solution: Use QUORUM for strong consistency!

๐Ÿ›’

Shopping Cart

Data: Items in cart, quantities
Problem: Add iPhone + MacBook concurrently
Impact: Last-Write-Wins โ†’ iPhone lost!
Risk: Silent item deletion, angry customers
Business: Lost sales, support tickets
User Tolerance: Absolutely zero
Solution: QUORUM or append-only design!

๐Ÿ“ฆ

Inventory Counts

Data: Stock levels, available quantity
Problem: Two users buy last item (concurrent)
Impact: Both see "1 available" โ†’ both purchase
Risk: Overselling - ship 2, have 1!
Business: Financial loss, refunds, angry customers
User Tolerance: Zero - business-critical
Solution: QUORUM + Lightweight Transactions!

๐Ÿ’ฐ

Account Balances

Data: Bank balance, wallet funds
Problem: Concurrent deposit + withdrawal
Impact: Math wrong! $100 + $50 - $30 = ???
Risk: Money lost or duplicated
Business: Financial catastrophe, regulatory violation
User Tolerance: Absolutely zero
Solution: QUORUM + transactions + audit trail!

๐ŸŽซ

Booking/Reservations

Data: Hotel rooms, flight seats, event tickets
Problem: Two users book same seat concurrently
Impact: Double-booking - both confirmed!
Risk: One customer has no seat at event
Business: Reputation damage, refunds, lawsuits
User Tolerance: Zero - mission-critical
Solution: QUORUM or pessimistic locking!

๐Ÿ”

Access Control

Data: Permissions, roles, ACLs
Problem: Revoke access โ†’ user still has access!
Impact: Stale permission = security breach
Risk: Unauthorized access to sensitive data
Business: Data breach, compliance violation
User Tolerance: Zero - security-critical
Solution: QUORUM + immediate propagation!

๐Ÿšจ Critical Warning

Common thread: Danger zones involve (1) User-facing critical data, (2) Financial/business impact, (3) Concurrent writes likely, (4) Immediate consistency expected, (5) Accuracy required. If your data matches these traits โ†’ DO NOT use eventual consistency! Use QUORUM or stronger. The performance "benefit" of eventual is not worth data corruption!

๐Ÿข How Real Companies Use Eventual Consistency

๐Ÿฆ Twitter: Billions of Timeline Updates

Scale: 500M tweets/day, 400M active users, billions of timeline loads
Challenge: Users scroll timelines constantly - need sub-5ms performance

โœ“ Eventual Consistency Use Cases:

1. Home Timeline (ONE + ONE):
โ€ข When you tweet โ†’ appears in followers' timelines
โ€ข Written with CL=ONE to timeline cache (3-5ms)
โ€ข Follower refreshes โ†’ might not see tweet yet (stale!)
โ€ข Refresh again 2 seconds later โ†’ tweet appears โœ“
โ€ข Why acceptable: Users expect refresh to see updates
โ€ข Performance: 100,000+ timeline reads/sec per node

2. Like/Retweet Counters (ONE):
โ€ข Billions of likes per day
โ€ข Each like written with CL=ONE (2-3ms)
โ€ข Count might show "12.3k" then "12.4k" (eventual)
โ€ข Why acceptable: Approximate counts fine
โ€ข Performance: Instant like button response

3. Trending Topics (ONE):
โ€ข Aggregate hashtag counts
โ€ข High-volume writes (millions/min)
โ€ข Trends updated every few minutes anyway
โ€ข Why acceptable: Batch-processed aggregates

โŒ Strong Consistency Cases:

1. Tweet Content (QUORUM):
โ€ข The actual tweet text/media
โ€ข User posts โ†’ must see their tweet immediately!
โ€ข CL=QUORUM for writes (12-15ms)
โ€ข Why necessary: "Where's my tweet?!" = bad UX

2. User Profiles (QUORUM):
โ€ข Username, bio, profile pic
โ€ข User updates โ†’ expects immediate reflection
โ€ข CL=QUORUM prevents ghost data

Result: Twitter handles billions of operations/day by using eventual for high-volume non-critical (timelines, likes) and strong for user-facing critical (tweets, profiles). Hybrid strategy = massive scale + good UX!

๐Ÿ“˜ Facebook: Eventual for Social Engagement

Scale: 3B+ users, billions of posts/reactions/comments daily
Strategy: Different consistency per feature

โœ“ Eventual (CL=ONE):

Reactions (Like, Love, Haha, etc.):
โ€ข Billions of reactions per day
โ€ข Each reaction written with ONE (2-3ms)
โ€ข Count convergence within seconds
โ€ข "12.3k reactions" vs "12.4k" immaterial

News Feed Algorithm Signals:
โ€ข Clicks, dwell time, interactions
โ€ข Massive volume of behavioral events
โ€ข Batch-processed for ML models
โ€ข Staleness of seconds acceptable

Friend Suggestions:
โ€ข Graph traversal results cached
โ€ข Updated periodically (eventual)
โ€ข "You might know X" = not time-critical

โš–๏ธ Strong (CL=QUORUM):

Posts & Comments:
โ€ข User posts status โ†’ checks profile โ†’ must see it!
โ€ข QUORUM prevents ghost posts
โ€ข 10-15ms acceptable for posting

Friend Relationships:
โ€ข Add/remove friend actions
โ€ข Must be immediately consistent
โ€ข QUORUM ensures no ghost friends

Engineering Insight: Facebook's infrastructure team: "We use eventual consistency for anything that's volume-driven and approximate. The 2-5 second convergence window is invisible to users for reactions and feed rankings. But posts and friendships need QUORUM - users notice inconsistency there immediately!"

๐Ÿ’ผ LinkedIn: Profile Views with Eventual

Scale: 900M+ members, billions of profile views
Feature: "523 people viewed your profile this week"

Profile View Counter (ONE):
โ€ข When someone views your profile โ†’ counter incremented
โ€ข CL=ONE for counter write (2-3ms)
โ€ข Massive volume: millions of profile views per minute
โ€ข Count might be slightly off during convergence
โ€ข "523 vs 524" = user doesn't notice/care

Why Eventual Works:
โ€ข Counter is approximate by nature
โ€ข Users check weekly, not real-time
โ€ข Delay of hours acceptable
โ€ข Volume requires speed (can't use QUORUM)

Convergence Pattern:
T=0: Profile viewed โ†’ Write ONE (3ms)
T=50ms: Background replication completes
T=1 hour: Batch job aggregates counts
T=daily: User sees: "523 views this week"

But Profile Updates (QUORUM):
โ€ข When user updates job title, bio, photo
โ€ข Must use QUORUM (10-15ms)
โ€ข User expects to see change immediately
โ€ข Ghost data = "did my update save?"

Pattern: Eventual for counters/metrics, strong for user-facing content. This lets LinkedIn handle massive scale while maintaining good UX!

โœ… Best Practices for Eventual Consistency

1๏ธโƒฃ

1. Know Your Convergence Window

Measure: Actual convergence time in production
Tool: nodetool tpstats, custom metrics
Typical: 20-100ms in healthy cluster
Monitor: Set alerts for slow convergence
SLA: Define acceptable staleness window
Test: Load test to verify under pressure

2๏ธโƒฃ

2. Design for Idempotency

Principle: Same write applied twice = same result
Pattern: Use timestamps, UUIDs for uniqueness
Example: SET email (idempotent) vs ADD item (not!)
Benefit: Safe to retry writes
Avoids: Duplicate data from retries
Test: Verify double-write = same state

3๏ธโƒฃ

3. Use Append-Only When Possible

Pattern: Never UPDATE, only INSERT
Example: Shopping cart = separate row per item
Benefit: No conflict risk (no overwrites!)
LWW safe: Each row independent
Query: SELECT all, aggregate client-side
Trade-off: More storage, but conflict-free

4๏ธโƒฃ

4. Monitor Clock Skew

Critical: LWW depends on synchronized clocks!
Tool: NTP monitoring, ntpstat
Alert: Clock drift > 100ms
Impact: Skewed clock = wrong data wins
Fix: Ensure NTP running on all nodes
Test: Simulate clock skew in staging

5๏ธโƒฃ

5. Set Read Repair Properly

Mechanism: Fix inconsistencies during reads
Setting: read_repair_chance (0.0-1.0)
Recommendation: 0.1 for eventual tables
Trade-off: Performance vs faster convergence
Monitoring: Track read repair metrics
Tune: Based on staleness tolerance

6๏ธโƒฃ

6. Document Your Choices

For each table: Document why ONE is safe
Include: Staleness tolerance, volume, criticality
Review: Quarterly consistency strategy audit
Share: Team understanding of trade-offs
Prevent: "Why is this table eventual?"
Update: As requirements change

7๏ธโƒฃ

7. Test Concurrent Writes

Simulate: Two users updating same row
Verify: LWW behavior as expected
Check: No silent data loss
Tool: Chaos testing, load generators
Monitor: Conflict resolution metrics
Alert: High conflict rates

8๏ธโƒฃ

8. Run Regular Repairs

Tool: nodetool repair
Frequency: Weekly recommended
Purpose: Fix any divergent data
Schedule: Off-peak hours
Monitor: Repair completion, data synced
Critical: Especially for eventual tables!

9๏ธโƒฃ

9. Plan for Stale Reads

Accept: Stale reads will happen
UI: Design for eventual updates
Pattern: "Refresh to see latest"
Avoid: Critical decisions on stale data
Fallback: QUORUM read if critical
Communicate: User expectations

โš ๏ธ Common Mistakes to Avoid

  • โŒ Using ONE for user-facing critical data: Ghost data = terrible UX!
  • โŒ Assuming "eventual = a few seconds": Can be longer if nodes slow/down
  • โŒ Ignoring clock skew: Kills LWW reliability, corrupts data
  • โŒ Not testing concurrent writes: Conflicts in production = surprise!
  • โŒ UPDATE instead of append-only: Conflicts guaranteed with concurrent writes
  • โŒ No monitoring of convergence: How do you know if it's working?

๐Ÿ’ผ Interview Questions & Answers

1
Explain eventual consistency. How is it different from strong consistency?

Complete Answer:

Eventual consistency is a consistency model where updates to a distributed system eventually propagate to all replicas, but there's no guarantee of immediate consistency across all nodes.

The Core Promise:

"If no new updates are made to a given data item, eventually all accesses to that item will return the last updated value."

This means that replicas may be temporarily inconsistent, but they will converge to the same value over time.

Eventual vs Strong Consistency:

Eventual Consistency (CL=ONE in Cassandra):

  • Write behavior: Write succeeds when ONE replica acknowledges (3-5ms)
  • Other replicas: Updated in background (20-100ms)
  • Read behavior: Might read from stale replica
  • Stale probability: 66% (2/3 replicas not yet updated)
  • Formula: R + W = 1 + 1 = 2 โ‰ค RF=3 (no overlap guarantee)
  • Performance: Very fast (3-5ms)
  • Scalability: Excellent (50k+ ops/sec)

Strong Consistency (CL=QUORUM in Cassandra):

  • Write behavior: Write waits for majority (2/3) to acknowledge (12-18ms)
  • Read behavior: Queries majority (2/3) replicas
  • Guarantee: R + W > RF (2 + 2 = 4 > 3) โ†’ overlap guaranteed
  • Stale probability: 0% (always reads latest write)
  • Performance: Slower (12-18ms, 4x slower than ONE)
  • Scalability: Good but limited (25k ops/sec)

Trade-offs Comparison:

Aspect Eventual Strong
Latency 3-5ms (fast!) 12-18ms
Stale Reads Possible (66%) Never
Throughput 50k+ ops/sec 25k ops/sec
Availability High (1/3 OK) Good (2/3 OK)
Use Case Timelines, counters User profiles, orders

Real-World Example:

Twitter timeline updates:

  • You post tweet โ†’ CL=ONE โ†’ 3ms response โœ“
  • Follower refreshes immediately โ†’ might not see tweet (stale replica)
  • Follower refreshes 2 seconds later โ†’ sees tweet (converged!)
  • This is acceptable because users expect refresh behavior
  • Twitter handles billions of timeline updates this way!

When to Use Each:

  • Eventual: High-volume, non-critical, approximate data (analytics, likes, timelines)
  • Strong: User-facing, critical, must be accurate (profiles, purchases, balances)

Key Insight: Eventual consistency trades immediate consistency for performance and scalability. The "eventual" convergence typically happens in 20-100ms, not hours. The key is knowing which data can tolerate this window!

Advertisement

Responsive Ad