LESSON 03 · Copies and placement

Replicate across failure domains

Keep independent physical copies so one node does not own the only durable value.

SYSTEM VIEW

The storage path

Diagram view
Machines—
Racks—
Copies left—

Watch one key choose three copies by walking the ring, then lose a rack.

  1. The Coordinator hashes order:42 to 58 and walks clockwise to A1 at 63, so Node A owns it. Partitioning gives the key one home and no spare: if Node A fails, order:42 is lost or unreachable.

    hash(order:42)
    58
    Owner
    A1 at 63 · Node A

    What changed

    • order:42 on Node A
  2. For three copies, take the next three tokens from 58: A1 at 63, A2 at 75 and B1 at 88. A1 and A2 are both Node A’s virtual nodes, so the three copies sit on two machines, and Node A failing takes two at once.

    Next 3 tokens
    A1, A2, B1
    Machines
    A, A, B

    What changed

    • Copies on A, A and B
  3. Skip any token whose machine already holds a copy: A1, skip A2, then B1 and C1 at 3. Nodes A, B and C are N = 3 distinct physical replicas; the Coordinator sends reads and writes to them. But A and B share rack 1.

    Walk from 58
    A1, B1, C1 (skip A2)
    Racks
    1, 1 and 2
    When put() acks
    not set by placement

    What changed

    • Copies on A, B and C
  4. A failure domain is a set of machines that can fail together, such as a rack sharing a power feed and switch. Rack 1 fails, taking Nodes A and B. Only Node C’s copy remains, so a put needing two acknowledgments gets one and fails.

    Rack 1
    Node A and Node B
    Put needs
    2 acks · gets 1

    What changed

    • Rack 1 down: A and B
    • 2 of 3 copies
  5. Now the walk also skips a used rack: from 58 it takes A1 on rack 1, skips A2 and B1, then takes C1 on rack 2 and D1 on rack 3. Cassandra’s NetworkTopologyStrategy and Kafka’s rack-aware replica assignment exist to prevent copies sharing a rack.

    Copies
    A1, C1, D1
    Racks
    1, 2 and 3

    What changed

    • Rack 1 back
    • Copies on A, C and D
  6. Rack 1 fails again and takes Node A with Node B. Node C on rack 2 and Node D on rack 3 still hold order:42, so two copies are left, and a put that needs two acknowledgments gets both and succeeds.

    Rack 1
    Node A and Node B
    Put needs
    2 acks · gets 2

    What changed

    • Rack 1 down: A and B
    • Put acked by C and D
  7. Three copies triple the stored bytes: 2 TB of keys becomes 6 TB, and every put becomes three writes. A copy in another region adds bandwidth and, if the client waits, tens of milliseconds. For data you can regenerate, one copy may be right.

    Stored
    2 TB × 3 = 6 TB
    Each put
    3 writes
    Another region
    + tens of ms

    What changed

    • Rack 1 back
    • 3 writes per put

Space plays · ← → step · Home resets

THE IDEA

How it works

Replication keeps extra copies of each key on other machines, so a machine failure neither loses the key nor makes it unreachable. For each key choose N distinct physical replicas, often by walking a placement ring clockwise and skipping positions that belong to a machine already chosen. A coordinator sends reads and writes to them. Distinct virtual nodes on one machine are not distinct safety copies.

A failure domain is a set of machines that can fail together: a server, a rack sharing a power feed and switch, or a data center. Place copies across the domains your availability goal names. As an example, with N = 3 on hosts in three racks, losing one rack leaves two copies. If two copies share a rack, the same event leaves one, and a write that needs two acknowledgments now fails. Cassandra’s NetworkTopologyStrategy and Kafka’s rack-aware replica assignment exist to prevent this.

Copies have a price. Three copies triple the stored bytes, every write becomes three writes, and a copy in another region adds bandwidth and, if the client waits for it, tens of milliseconds. For data you can regenerate, one copy may be the right answer. Copies can also temporarily differ. Partitioning answers where a key belongs; replication answers where additional copies belong. Neither alone defines when put() acknowledges success or which version get() returns.

DECISION POINT

Three virtual-node copies sit on one physical server. Does N = 3 protect against its failure?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • N counts independent physical replicas.
  • Failure-domain placement matters as much as copy count.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 2
DiagnoseQUESTION 01

A key has three copies on three hosts in one rack. A switch failure makes the key unreachable, yet no disk was lost. What was wrong?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 2 checkpoints answered correctly to complete this lesson.