Database.Middle.What is eventual consistency?

Eventual consistency is a consistency model used in distributed systems and databases where:

⚠️ Not all nodes are immediately consistent, but if no new updates are made, all replicas will eventually become consistent over time.

🧠 Real-World Analogy

Imagine you’re updating your profile picture on a global social network. You update it in Russia, but a friend in the US still sees the old picture for a few seconds. After a short delay, they see the new one.

That’s eventual consistency — the system prioritizes availability and performance, with temporary inconsistency allowed.

📚 Key Characteristics

PropertyDescription
Temporary inconsistencyReads may return stale data
High availabilityNodes can serve requests even if out of sync
No strict orderingUpdates can be applied in different order
ConvergenceEventually, all replicas apply all updates

🆚 Compared to Strong Consistency

FeatureStrong ConsistencyEventual Consistency
Read after writeAlways reflects latest writeMight return stale data
LatencyHigherLower
AvailabilityLower in partition failuresHigher
Use casesBanking, critical appsSocial feeds, caching, DNS

🛠️ Where It’s Used

  • Amazon DynamoDB
  • Cassandra
  • MongoDB (in eventual consistency mode)
  • DNS systems
  • CDNs (Content Delivery Networks)

🔄 Techniques to Achieve Eventual Consistency

  • Background synchronization
  • Conflict resolution (last-write-wins, vector clocks, CRDTs)
  • Quorum-based writes/reads (e.g., read from R, write to W, where R + W > N)

🧰 Example: Amazon Dynamo

  • Writes propagate to multiple replicas asynchronously
  • A read may hit a stale node, but the system will repair it in the background

✅ Benefits

  • High availability
  • Better performance
  • Scales well in distributed environments

⚠️ Trade-offs

  • Data might be inconsistent temporarily
  • Requires app developers to handle conflicts or stale reads

🔍 Summary

TermMeaning
Eventual consistencyAll nodes will agree eventually, not immediately
When to use itFor systems where real-time accuracy isn’t critical
BenefitsSpeed, fault tolerance, scalability
DrawbacksComplexity, stale reads
This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.