LearnViz CompSci
Home / Learn / Databases / Eventual Consistency

Advanced Topic 45 of 51 Databases

Eventual Consistency

Replicas converge to the same state given time.

How it works

Eventual consistency is a guarantee that if no new updates are made, all replicas of a data item will converge to the same value after some time. Updates propagate asynchronously, so a read right after a write may return old data from a replica. Techniques that help include read repair, anti-entropy with Merkle trees, vector clocks, last-write-wins and conflict-free replicated data types, plus quorum reads and writes to tune freshness.

Step-by-step walkthrough

  1. The client writes x = 2 to replica 1.
  2. A read from replica 2 still returns the old x = 1.
  3. Replica 1 propagates the update.
  4. After a short time replica 2 has x = 2.
  5. Replicas converge when no new writes arrive.

Where it is used

Shopping carts, social feeds, DNS, caches, collaborative editing and globally replicated stores favor eventual consistency for availability and low latency.

Common pitfall

Applications may see stale or out-of-order data and conflicting concurrent writes that must be merged correctly. Last-write-wins can silently lose updates and depends on clocks. Design the user experience for temporary inconsistency, use idempotent operations and apply stronger consistency to critical operations like payments or inventory counts.

Where it fits in the course

Eventual Consistency is topic 45 of 51 in Databases, rated Advanced. It follows CAP Theorem. The next topic is Data Warehousing.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Databases quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Eventual Consistency?
Replicas converge to the same state given time. It belongs to Databases and is an advanced-level topic.
Where do people use Eventual Consistency?
Shopping carts, social feeds, DNS, caches, collaborative editing and globally replicated stores favor eventual consistency for availability and low latency.
What is the most common mistake with Eventual Consistency?
Applications may see stale or out-of-order data and conflicting concurrent writes that must be merged correctly.
What should I learn before this topic?
Start with CAP Theorem, the topic just before it in Databases.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Databases quiz.
Is Eventual Consistency hard to learn?
It is an Advanced topic. Expect to read the explanation more than once and to connect it with earlier topics. Working through a small example by hand helps most.
How long does it take to learn Eventual Consistency?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Eventual Consistency?
CAP Theorem, Data Warehousing, Graph Databases are closely connected. The full list is in the related topics section of this page.
What should I study after Eventual Consistency?
Continue with Data Warehousing, the next topic in Databases.

Related topics