System DesignIntermediate16 min

Consistency models & CAP in practice

Understand what guarantees you are really buying when you pick a database or a replication mode.

See it on the map

CAP says that when a network partition happens, a system must choose between consistency and availability. It is a statement about behaviour during failure, not a label for a database. Most real decisions are about the everyday trade between latency and consistency, not partitions.

Strong consistency means every read sees the latest write, which costs coordination and latency. Eventual consistency means replicas converge if writes stop, which is cheap and fast but needs your application to tolerate temporary disagreement.

Between the two sit useful middle grounds: read-your-writes, monotonic reads, and causal consistency. Pick the weakest guarantee that keeps your users from noticing, then use strong consistency only where money or correctness demands it.

Key points

  • CAP is about partitions. Day-to-day, think latency versus consistency.
  • Use the weakest consistency that keeps the product correct.
  • Money movement and inventory counts usually need strong consistency. Feeds and counters usually do not.
  • Conflicts need a rule: last write wins, merge, or ask the user.

Answer these out loud

  1. 1A like counter is eventually consistent. Is that acceptable? What about a bank balance? Explain the difference.
  2. 2Two users edit the same record in different regions. Sketch two conflict-resolution strategies.

Use this from an agent

Any MCP client, including Grok, can read this lesson. See how to connect.

REST
curl https://engineeros-delta.vercel.app/api/v1/topics/consistency-and-cap

This unlocks