Scrivio Interview library
DebuggingIntermediate7 min read · updated 13 November 2026

A Cassandra cluster was created with num_tokens set to 4 and random token allocation, to make repairs cheaper. After three nodes were added, nodetool status shows effective ownership from 4 to 14 percent per node, and the 14 percent node has twice the disk use and read latency of the others.

Explain why so few tokens give such skewed ownership, how you would confirm it, and how you would fix it on a running cluster.

With only 4 random tokens per node, each node's share of the ring is the sum of 4 random gaps, and such small sums vary a lot, so ownership from 4 to 14 percent is expected rather than unlucky. We confirm it with nodetool status for the keyspace, nodetool ring and per-node disk and request metrics, ruling out a hot partition. Tokens of existing nodes cannot be changed in place, so we fix it by adding or replacing nodes with the token allocation algorithm enabled, one at a time, or by building a new data center with good tokens, throttling streaming and running nodetool cleanup as we go.

Why this question is asked

Lowering num_tokens is a sensible idea: fewer tokens mean fewer ranges to repair and less metadata. The trap is that with random placement, few tokens give poor balance, and once a node has joined with its tokens, they are fixed. Interviewers ask this debugging scenario because the fix on a live cluster is a careful operation, not a configuration change. In this answer, we will explain why 4 random tokens produce this skew, confirm the diagnosis and rule out alternatives, see why the tokens cannot simply be changed, and walk through the two ways to fix the cluster safely.

1A Quick Recap: Tokens and Ownership

In Cassandra, each node owns a set of tokens on a hash ring, and each token marks the end of a range of the ring that the node is primary for. A node's ownership is the total length of its ranges as a fraction of the ring, and effective ownership also counts the ranges it holds as a replica for other nodes. Data and requests are spread according to ownership, so a node that owns twice as much stores twice as much and serves about twice as many requests.

2Why 4 Random Tokens Give Such Skew

When tokens are chosen at random, the gaps between them are random too, and random gaps are very uneven: on a ring with many random points, it is normal for some gaps to be five or ten times longer than others. A node's ownership is the sum of the gaps behind its tokens. With 256 tokens, that sum averages out over many gaps and every node ends up close to the mean. With 4 tokens, the sum is over only four gaps, so a node that happens to draw two long gaps owns far more than one that draws four short ones.

Roughly, the relative spread shrinks with the square root of the token count, so 4 tokens leave about 8 times more imbalance than 256. Observed ownership from 4 to 14 percent, a factor of 3.5 between the smallest and largest nodes, is exactly what this predicts. And because disk use and read traffic follow ownership, the 14 percent node has about twice the disk use of an average node and the highest read latency.

Effective ownership after adding three nodes (illustrative)
NodeEffective ownershipDisk usedRead p99
node 114 percent2.1 TB38 ms
node 29 percent1.3 TB14 ms
node 37 percent1.0 TB11 ms
node 9 (new)4 percent0.6 TB9 ms
Disk and latency follow ownership, which points at token placement.

3Confirming the Diagnosis

Before acting, we make sure ownership is really the cause. nodetool status with a keyspace name shows effective ownership including replication for that keyspace; without a keyspace it can be misleading when keyspaces have different replication settings. nodetool ring lists every token and its owner, so we can see the uneven gaps directly. Then we compare per-node metrics: if disk use, read and write request counts all scale with ownership across all nodes, token placement is the explanation.

Text
nodetool status shop # Owns (effective): 14.0%, 9.1%, 6.8%, ..., 4.0%
nodetool ring shop # tokens per node and their positions
nodetool tablestats shop.orders | grep -i 'space used'
nodetool toppartitions shop orders 10000 # sample the hottest partitions for 10 s

The alternative we must rule out is a hot partition: one very large or very busy partition key on that node would also raise its disk and latency. toppartitions (or the per-table partition size histograms in tablehistograms) shows whether one key dominates. If the excess is spread over many partitions in proportion to ownership, it is placement; if one key stands out, it is a data model problem that new tokens would not fix.

4Why the Tokens Cannot Simply Be Changed

A node's tokens are fixed when it bootstraps: it picks or is given its tokens, streams the data for those ranges from other replicas, and starts serving. Changing num_tokens in cassandra.yaml afterwards does nothing for that node; Cassandra stores the tokens it already has and refuses to start if the configured count does not match. There is no supported operation to reassign an existing node's tokens in place. So the fix is not to edit nodes but to replace them: bring in nodes whose tokens are chosen well, and retire nodes whose tokens are bad.

Good tokens come from the token allocation algorithm. Instead of drawing tokens at random, a joining node examines the current ring and chooses tokens that balance ownership for a given replication factor. In Cassandra 4.x it is enabled with allocate_tokens_for_local_replication_factor, and the default configuration uses num_tokens 16 with that set to 3; check the exact option names and defaults for your version. It only applies to nodes as they join.

5Fix 1: Replace Nodes One at a Time

On a cluster of modest size, we roll through the nodes. We set the allocator in the configuration for new nodes, using the same num_tokens as the cluster or one the allocator handles well, then bootstrap one new node and let it finish streaming, and then decommission one of the worst old nodes, which streams its data to the remaining replicas. Starting with the most overloaded node gives relief first. After each step, we run nodetool cleanup on nodes that gave away ranges, check nodetool status again, and only then continue.

This takes time, because every node's data is streamed at least once, but each step is a normal, well-tested operation, and the cluster stays fully available at the same replication factor throughout.

Step throughOne round of the rolling fix
  1. Bootstrap a new node with the allocator ontokens chosen to balance ownership
  2. Wait for streaming to finishnodetool netstats shows progress
  3. Decommission the most overloaded old nodeits ranges stream to the remaining replicas
  4. Run nodetool cleanup on nodes that gave away rangesreclaims disk
  5. Ownership balanced across all nodes?
    YesDoneNoRepeat with the next old node

5 steps in order. Play them, or step through them one at a time.

6Fix 2: A New Data Center, and Doing It Safely

For larger clusters, or when we also want to change num_tokens, a cleaner path is a new logical data center. We create dc2 with nodes using the allocator, add dc2 to every keyspace's replication, run nodetool rebuild on the new nodes to stream all data from dc1, move clients to dc2 with LOCAL_QUORUM, and then remove dc1 from replication and decommission it. It needs double the hardware for a while but gives a completely fresh, balanced ring.

Either way, streaming competes with live traffic, and the overloaded node is the one we must protect most. We throttle streaming with stream_throughput_outbound (or nodetool setstreamthroughput), run the work off-peak, and watch read latency throughout. And nodetool cleanup matters: when a new node takes over ranges, the old owners keep their copies of that data on disk until cleanup removes it.

7Follow-up questions

Why does nodetool cleanup matter after nodes join?

When a node joins and takes over some ranges, the nodes that used to own them do not delete their copies automatically, so their disks keep data they no longer serve. nodetool cleanup rewrites their SSTables without the ranges they no longer own, freeing that space. Until it runs, disk use looks as skewed as before even though ownership has changed. It is I/O heavy, so it is run one node at a time, off-peak.

Could you use 4 tokens with the allocator instead of 16?

Possibly, since the allocator chooses tokens deliberately, but very few tokens still limit how evenly ranges can be divided when nodes are added later and concentrate rebuild streaming on few peers. 16 with the allocator is the usual compromise between balance, repair cost and rebuild speed.

Is it safe to change num_tokens for new nodes only?

Nodes can have different token counts, and Cassandra weights ownership by the number of tokens, so a node with more tokens owns more. Mixing counts deliberately can be used to weight bigger machines, but by accident it creates exactly the imbalance we are trying to fix.

8Conclusion

In this answer, we saw that 4 random tokens per node make each node's ownership the sum of only four random gaps, so a 3.5 times spread between nodes is expected, and disk and latency follow it. We confirmed it with nodetool status for the keyspace, nodetool ring and per-node metrics, and ruled out a hot partition with toppartitions. Since tokens cannot be changed in place, we fixed the cluster by bootstrapping new nodes with the token allocation algorithm and decommissioning bad ones one by one, or by building a balanced new data center, throttling streaming and running nodetool cleanup after each step.

What to say in the interviewAbout 90 seconds aloud

Open with

With only four tokens per node and random placement, each node's share of the ring is the sum of four random gaps, and random gaps vary a lot, so some nodes get two long gaps and own three times as much as others.

Then, if they want more

That matches 4 to 14 percent. Disk use and read latency follow ownership, so the 14 percent node has double the disk and the worst latency.

To confirm, I would run nodetool status with the keyspace name, so it shows effective ownership including replication, and nodetool ring to see the token positions, then check that disk and request counts on every node scale with ownership. I would also run toppartitions to rule out a single hot partition, which new tokens would not fix.

The fix is awkward because tokens are fixed when a node bootstraps; you cannot reassign them in place.

So I would turn on the token allocation algorithm, allocate_tokens_for_local_replication_factor, which in the 4.x default config goes with num_tokens 16, and roll through the cluster: bootstrap a new node with allocated tokens, decommission the most overloaded old node, run cleanup on nodes that gave away ranges, recheck ownership, and repeat.

For a big cluster, building a new data center with good tokens and moving to it is cleaner. Throughout, I throttle streaming and run it off-peak.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain why so few tokens give such skewed ownership, how you would confirm it, and how...": https://scrivio-interview-library.netlify.app/architecture/partitioning-and-replication/d3196fae4c/