stackbook.io
🔍
← Back to Syllabus
Day 10Level 1 — Trade-offs and Resilience

Consistency and the CAP Theorem Basics

Learn: 40 minMap: 25 minDesign: 45 min

Core Concepts (5)

  • 1.Strong consistency means every read sees the latest write
  • 2.Eventual consistency means replicas converge given time
  • 3.Network partitions force a choice between consistency and availability
  • 4.Different data in one system can need different guarantees
  • 5.State the consistency promise explicitly

Map to Your Experience

Recall seeing two screens disagree, such as an app balance and an email receipt. Which one was right, and for how long did they differ?

Design Brief: Pick Guarantees per Feature

Learn

Once data lives on more than one machine, a hard question appears: when someone writes a value, when do others see it? The answer is the consistency model.

Strong consistency promises that after a write completes, every read anywhere returns that value. It is easy to reason about, and it is what people expect from a bank balance. The cost is coordination: replicas must agree before answering, which adds latency and can make the system unavailable if they cannot talk.

Eventual consistency promises only that, if writes stop, all replicas will eventually hold the same value. In between, different readers may see different answers. It is faster and more available, and it suits things like like-counts, feeds, and search indexes, where a few seconds of difference harms nobody.

The CAP theorem gives the formal shape of the trade-off. A network partition means some nodes cannot reach others. During a partition, a system must choose: stay consistent by refusing some requests, which sacrifices availability, or stay available by answering from possibly stale data, which sacrifices consistency. Partitions will happen, so the real choice is what to do when they do.

Two cautions. CAP applies only during failures, and when the network is healthy you still trade consistency against latency. And the choice is not one per system. A single product often needs strong guarantees for payments and weaker ones for the activity feed.

The most practical habit is to state the promise out loud. Write a sentence such as: after a user changes their address, they see the new one immediately, while other users may see it within five seconds. Specific promises can be designed, tested, and communicated; vague ones lead to surprising bugs.

Map

Classify each as needing strong or eventual consistency and say why: bank transfer, number of video views, inventory count at checkout, profile photo change, seat selection on a flight.

Design

For a combined banking and social app, produce a table of six features, the consistency guarantee for each, and the user impact if the guarantee is violated. Then describe what each of two features does when the network between two data centres is cut for ten minutes: does it keep answering or does it refuse?

Requirements

  • •Classify 6 features
  • •Justify each with user impact
  • •Describe behaviour during a network partition

Constraints

  • •Money must never be created or lost
  • •Social feeds may be a few seconds stale

Must Cover

classificationuser-impactpartition-behaviour

Trade-off Axis

consistency vs availability and latency

Referenced Patterns

Competencies Advanced

data state → L2distribution communication → L1

Ready to Design?

Open this day in the Design Studio. The studio follows this track: its days, concepts, patterns and trade-offs are loaded, and you keep one design across the whole track.

Open in Studio →