Data Consistency/

Consistency

Lesson overview

Consistency

Consistency models in distributed databases.

Consistency means all nodes in a distributed system see the same data at the same time (or eventually).

Balance = 500

Balance = 400

Is this system consistent?

Consistency Models

Rules about when a read operation can see a write operation. It specifies how quickly updates become visible to other nodes.

Eventual Consitency

Strong Consitency

Casual Consitency

Weak Consistency

Monotonic Reads

Read-Your-Writes Consitency

Every read always returns the latest written value.

All replicas will eventually have the same value, but not immediately.

If one event causes another event, all users must see them in the same order.

The system does not guarantee when updates will be visible.

A user always sees their own updates immediately.

A user will never see older data after seeing newer data.

| Model | Guarantee | Example Use | | -------------------- | -------------------------------- | -------------------- | | Strong Consistency | Always latest data | Banking | | Eventual Consistency | Data becomes correct later | Social media | | Causal Consistency | Maintains event order | Chat systems | | Weak Consistency | No guarantee when update appears | DNS, caches | | Read-your-writes | User sees own updates | User posts | | Monotonic Reads | Never see older data | Replicated databases |

will update in master and in all the replica then it will return the response: it is slow: example: google spanner Banking System

will update in master and return the response and later updates the replica: it is fast: example: Social Media Likes Cassandra

User 1: "hello" User 2:"hi"

User 1: "hello" User2: "hi"

If A happens before B, then everyone must see A before B. Example: Chat Applications Comment

Loading Consistency