LESSON 05 · Virtual nodes

Use multiple tokens per physical node

Virtual nodes reduce uneven range sizes and can reflect unequal hardware capacity.

SYSTEM VIEW

The placement map

Diagram view
Largest share—
Smallest share—
Tokens—

Watch four machines swap one token each for three, then follow the slices a failure and a join move.

  1. This is the ring after D joined, one token per machine. Keys spread evenly, so each machine holds what its stretch covers: A owns 81 to 20, 40% of the ring, C 30%, and B and D only 15% each.

    Shares
    A 40 · B 15 · C 30 · D 15%
    A’s stretch
    81–20
    10 machines
    largest ≈ 3× average

    What changed

    • 40 keys
  2. Each machine now holds three tokens, its virtual nodes, so its stretches scatter round the ring: A owns 24%, B 25%, C 26%, D 25%. These positions are picked to balance; random ones need many more tokens, since the spread shrinks with the square root of tokens per machine.

    Shares
    A 24 · B 25 · C 26 · D 25%
    16 tokens each
    spread ≈ 25% of mean
    100 tokens each
    spread ≈ 10% of mean

    What changed

    • 1 → 3 tokens per machine
    • Largest share 40% → 26%
    • Smallest share 15% → 24%
  3. Node C fails, and all three of its tokens go with it: they are aliases for one machine, not replicas. Each slice passes to the next token clockwise: C2’s 97–4 to B2, C3’s 21–28 to D1, C1’s 71–80 to A3. A ends with 34%, B and D with 33%.

    C’s 26%
    A +10 · B +8 · D +8
    With one token
    all 30% to A
    10 machines
    10% → 9 × 1.1%

    What changed

    • Node C and its 3 tokens
    • A 34% · B 33% · D 33%
  4. Node E joins with tokens at 15, 44 and 66. Each takes a small slice from a different donor: 10–15 from A, 36–44 from B, 58–66 from D. E owns 24%; A drops to 28%, B and D to 24%.

    E1 at 15
    6 from A1
    E2 at 44
    9 from B1
    E3 at 66
    9 from D2

    What changed

    • Node E: 3 tokens, 24%
    • A 28% · B 24% · D 24%
  5. Every token is a ring entry that routing, membership and repair must track: A alone has three; 1,000 machines with 256 each make 256,000. A also shares ranges with more peers, so two failures at once are likelier to hit two copies of some range. Cassandra cut its default from 256 to 16 in 4.0.

    1,000 × 256 tokens
    256,000 ring entries
    Cassandra 4.0
    256 → 16 tokens
    2× hardware
    ≈ 2× tokens, measure load

Space plays · ← → step · Home resets

THE IDEA

How it works

With only one random token per machine, some machines receive large arcs and others tiny arcs; among 10 machines, the largest arc is typically around three times the average. A virtual node, or vnode, is one of several token positions assigned to a physical machine. Its intervals are spread around the ring, so variation falls as token count grows. As a rule of thumb, the spread in ownership shrinks with the square root of tokens per machine: a standard deviation near 25% of the mean at 16 tokens, and near 10% at 100.

Vnodes also change failures and joins. With one token, a failed machine’s whole range lands on one successor. With many, it falls to many successors: in a 10-machine example, the failed machine’s 10% spreads across nine survivors, about 1.1% each. A joining machine likewise takes small slices from many donors. A stronger machine can own more tokens, but that choice should be based on measured capacity and actual load.

A very large token count increases routing metadata, membership updates, and repair bookkeeping: 1,000 machines with 256 tokens each means 256,000 ring entries. A machine also shares ranges with more peers, so two simultaneous failures are more likely to hit two copies of some range. Cassandra lowered its default from 256 tokens to 16 in version 4.0. A token is a placement alias, not an extra replica or machine.

DECISION POINT

Two machines have identical capacity, but one owns a much larger ring interval. What change helps?

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

Keep in mind

  • Multiple tokens smooth random partition imbalance.
  • Virtual nodes increase metadata and do not create physical redundancy.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

What is a virtual node?

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

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.