Quick revision
The short answer
With a fixed number of partitions created up front (Redis Cluster's 16,384 slots, an Elasticsearch index's shards), a new node takes whole partitions from others, but the count is chosen once and caps the cluster. With dynamic splitting (HBase regions, range-based distributed SQL), ranges split and merge by size, so the count follows the data, though a new table starts as one range. With a fixed number of partitions per node (Cassandra tokens), a joining node takes over parts of existing ranges, so the count grows with the cluster. In all three, only the moving partitions are copied, unlike hash mod N.
What to remember
In this answer, we saw why hash mod N moves almost everything when N changes, and compared three ways to define partitions that move. Fixed partitions created up front, like Redis Cluster's 16,384 slots or Elasticsearch's primary shards, move whole to new nodes but cap the cluster and are hard to change. Dynamic ranges, as in HBase and distributed SQL, split and merge by size so the count follows data, but a new table starts on one range unless pre-split. Partitions per node, as in Cassandra, grow with the cluster as joining nodes take parts of existing ranges. Rebalancing should be throttled, and fully automatic moves combined with failure detection can make overloads worse.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With a fixed number of partitions created up front (Redis Cluster's 16,384 slots, an Elasticsearch index's shards), a new node takes whole partitions from others, but the count is chosen once and caps the cluster. With dynamic splitting (HBase regions, range-based distributed SQL), ranges split and merge by size, so the count follows the data, though a new table starts as one range. With a fixed number of partitions per node (Cassandra tokens), a joining node takes over parts of existing ranges, so the count grows with the cluster. In all three, only the moving partitions are copied, unlike hash mod N.
Why this question is asked
Every partitioned database eventually has to move data, because nodes are added, removed or replaced. The interesting design difference is not how they move data but what the unit of movement is and when those units are created. Interviewers ask this comparison because it explains why Redis, Elasticsearch, HBase and Cassandra behave so differently when we grow them, and why some early decisions are hard to undo. In this answer, we will see why hash mod N fails, walk through the three approaches with what moves when a node joins, compare them, and discuss whether rebalancing should be automatic.
1A Quick Recap: Why Not Hash Mod N
The naive way to partition is node = hash(key) mod N. It spreads keys evenly, but when N changes, almost every key changes node. Going from 4 to 5 nodes, a key stays put only if hash mod 4 equals hash mod 5, which is true for about 1 key in 5, so roughly 80 percent of the data moves. On a cluster with terabytes of data, that is a disaster. All three approaches below avoid it by introducing partitions, units of data that are larger than a key and smaller than a node, and moving only some of them.
2Approach 1: A Fixed Number of Partitions, Created Up Front
Here the system creates many more partitions than nodes at the very start, and that number never changes. Redis Cluster always has 16,384 hash slots; a key's slot is CRC16(key) mod 16384, and each node serves a set of slots. An Elasticsearch index is created with a fixed number of primary shards, and a document's shard is chosen by hashing its routing value modulo that number.
When a node joins, it takes whole partitions from the existing nodes until each node has a fair share; in Redis Cluster that means migrating some slots to the new node, and in Elasticsearch the cluster relocates some shards. The key-to-partition mapping never changes, only the partition-to-node mapping does, so routing stays simple.
The catch is the number itself. It caps the cluster: an index with 5 primary shards can never spread its writes over more than 5 nodes. And it is hard to change later. Choose too few, and partitions grow huge and slow to move; choose too many, and each partition has overhead (Elasticsearch shards each cost memory and file handles). Elasticsearch offers split and shrink APIs and reindexing for this, which shows that the decision is expensive to revisit.
3Approach 2: Ranges That Split and Merge by Size
Range-partitioned stores such as HBase, and distributed SQL databases such as CockroachDB and TiDB, create partitions dynamically. Each range covers a contiguous interval of keys. When it grows past a threshold, it splits into two; when neighbouring ranges become small, they merge. So the number of partitions follows the amount of data: a small table has a few ranges, a huge one has thousands.
When a node joins, the balancer moves some ranges to it, just as in approach 1, but because ranges keep splitting, there are always enough of them to spread around. The weakness is the beginning: a new, empty table is one range on one node until it grows enough to split, so early writes all hit one server. That is why these systems support pre-splitting a table at known key boundaries.
4Approach 3: A Fixed Number of Partitions per Node
Cassandra takes yet another approach. Each node owns a fixed number of tokens, num_tokens, and each token defines a range of the hash ring. So the number of ranges is proportional to the number of nodes, not fixed and not driven by data size. When a node joins, it picks its tokens, and each new token splits an existing range: the new node takes over the part of that range between the previous token and its own. Existing nodes keep the rest of their ranges.
So the number of partitions grows with the cluster, and each partition's size stays roughly proportional to data per node. There is no up-front count to get wrong, but balance depends on how tokens are chosen, which is why recent Cassandra versions use a token allocation algorithm instead of random tokens.
| Fixed partitions | Dynamic ranges | Partitions per node | |
|---|---|---|---|
| Example | Redis Cluster, Elasticsearch | HBase, CockroachDB, TiDB | Cassandra |
| Partition count | fixed at creation | follows data size | grows with node count |
| New node gets | whole partitions from others | whole ranges from others | parts of existing ranges |
| Key-to-partition mapping | never changes | changes on split or merge | changes as tokens are added |
| Main risk | count chosen badly, hard to change | new table starts on one range | uneven ownership with few random tokens |
5Should Rebalancing Be Automatic?
The moves themselves can be triggered automatically by the system or manually by an operator. Fully automatic rebalancing is convenient, but it has a dangerous combination with automatic failure detection. Suppose a node is slow because it is overloaded. The failure detector decides it is dead, the system starts moving its partitions to other nodes, and the streaming adds load to the nodes that were already busy, which makes them slow, which may make them look dead too. A cluster can talk itself into a cascading failure this way.
So many teams keep a human or at least a rate limit in the loop. Elasticsearch, for example, waits a configurable delay before reallocating the shards of a node that left, in case it comes back quickly, and limits concurrent recoveries. Redis Cluster leaves slot migration to an operator or a tool, and Cassandra node additions are operator-driven. Automatic is fine for small, routine moves; large moves should be planned, throttled and watched.
6Follow-up questions
How can you change the shard count of an existing Elasticsearch index?
The number of primary shards is fixed when the index is created, but there are three ways around it. The _split API creates a new index with a multiple of the original shard count, reusing the data through hard links, and the _shrink API creates one with a factor of the count; both require the source index to be read-only during the operation. Reindexing into a new index with any shard count works for any change but copies all the data. In both cases, an alias lets clients switch to the new index without changing their configuration.
Why does Redis Cluster use 16,384 slots and not 65,536?
The slot bitmap is exchanged in cluster heartbeat messages, and 16,384 slots fit in 2 KB while 65,536 would need 8 KB per message. Since Redis Cluster is designed for at most about 1,000 nodes, 16,384 slots are enough to spread data evenly.
Which approach fits a time-series workload?
Usually dynamic ranges or time-based partitions, because data grows continuously and old data becomes cold. Ranges follow the growth, but the key must not start with the timestamp, or every write hits the last range.
7Conclusion
In this answer, we saw why hash mod N moves almost everything when N changes, and compared three ways to define partitions that move. Fixed partitions created up front, like Redis Cluster's 16,384 slots or Elasticsearch's primary shards, move whole to new nodes but cap the cluster and are hard to change. Dynamic ranges, as in HBase and distributed SQL, split and merge by size so the count follows data, but a new table starts on one range unless pre-split. Partitions per node, as in Cassandra, grow with the cluster as joining nodes take parts of existing ranges. Rebalancing should be throttled, and fully automatic moves combined with failure detection can make overloads worse.
Open with
With hash mod N, changing N moves most keys, so all real systems move partitions instead, and the question is how partitions are defined. The first approach fixes the number of partitions up front: Redis Cluster always has 16,384 hash slots, and an Elasticsearch index has a fixed number of primary shards.
Then, if they want more
A new node takes whole partitions from the others, and the key-to-partition mapping never changes. The downside is that the count caps how far you can scale and is hard to change, in Elasticsearch you need split, shrink or a reindex.
The second approach is dynamic: HBase regions or ranges in distributed SQL split when they pass a size threshold and merge when small, so the partition count follows the data size. A new node gets some whole ranges. The weakness is that a new table starts as a single range unless you pre-split it.
The third is a fixed number of partitions per node, like Cassandra's tokens: a joining node picks tokens and takes over parts of existing ranges, so the number of ranges grows with the cluster. In all three, only the moving partitions are copied.
And I would be careful with fully automatic rebalancing combined with automatic failure detection, because moving data off a slow node adds load and can cascade, so I want rate limits or a human decision for big moves.
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 "Compare three rebalancing approaches: a fixed number of partitions created up front...": https://scrivio-interview-library.netlify.app/architecture/partitioning-and-replication/9b5d5423ad/