Simple hash-based sharding assigns each key using its hash modulo the shard count. Add or remove a shard, and many keys land elsewhere, triggering costly data movement. Consistent hashing reduces that churn by limiting how many keys need to shift when the cluster changes.

Multiple Choice

What is a major downside of simple hash-based sharding without consistent hashing?

The key idea is that simple hash-based sharding maps keys to shards using a hash modulo the number of shards. When the number of shards changes—adding or removing a shard—the modulo result changes for many keys, so many items get assigned to different shards. That means you must move a large portion of the data to re-balance, which is costly and disruptive. This is exactly why adding or removing shards leads to migrating most of the data in a non-consistent hashing scheme. Consistent hashing avoids this by mapping keys to positions on a ring and only moving a small fraction of keys when the topology changes. So the correct takeaway is that changing the shard count alters the modulo for most keys, causing widespread data movement. The other statements don’t capture that large-scale relocation that happens with simple modulo-based hashing.

Why Simple Hash-Based Sharding Can Make Growth Painful

Sharding helps a system spread data across several machines. Instead of asking one server to store and serve everything, the system divides records among smaller groups called shards. That can improve capacity and keep requests moving as a service grows.

But there’s a catch: the way data is assigned to shards matters. A simple approach uses a hash function and the number of available shards. It’s easy to understand and quick to set up. Yet when the shard count changes, that simplicity can turn into a costly reshuffle.

The simple rule behind modulo sharding

Imagine a service with four storage shards. For each key—perhaps a user ID or order number—the system calculates a hash, then divides that value by four. The remainder tells it which shard should hold the record.

In shorthand:


shard = hash(key) % number_of_shards

The percent sign represents the modulo operation: it returns the remainder after division. If a key’s hash value is 19 and the system has four shards, the remainder is 3. That key goes to shard 3, assuming the shards are numbered from 0 to 3.

This rule is appealing because it’s compact. It spreads keys across the available shards, and engineers can reason about it without a complicated routing layer. For a small system with a fixed set of machines, that may be all they need.

The trouble starts when the set of machines doesn’t stay fixed. And real systems rarely do.

Add one shard, and the map changes

Suppose the service grows from four shards to five. The assignment rule now divides each hash by five instead of four. Many keys that once produced one remainder will produce another. Their destination changes, even though the keys themselves haven’t changed.

For example, a hash value of 19 maps to shard 3 with four shards:


19 % 4 = 3

With five shards, it maps to shard 4:


19 % 5 = 4

One key has moved. The same shift occurs across a large share of the keyspace. In a roughly even distribution, changing the shard count can cause most keys to receive a new destination. A common rough estimate is that only about one out of every N keys stays put when moving from N shards to N + 1 shards, though exact results depend on the hash function and the data.

That means adding a machine isn’t just a matter of plugging it in and sending it new traffic. The system may need to copy a large amount of existing data to match the new mapping. During that move, storage, network bandwidth, and database capacity all come under extra strain.

Removing a shard causes a similar problem. If a machine fails or needs to be retired, the system recalculates destinations using a smaller shard count. Once again, many keys point somewhere else. The remaining machines must absorb the records from the lost shard, along with any other data whose new destination has changed.

Why moving data is more than a background chore

A large data migration can be slow and expensive. It also creates operational risks. The system must keep data available while records are copied, updates continue to arrive, and routing changes take effect.

A poorly managed move can lead to stale reads, duplicate records, uneven load, or temporary outages. Even when the migration is carefully planned, it competes with ordinary requests for disk and network resources. Users may notice slower responses, while engineers watch dashboards and hope the traffic line stays calm.

There’s also a coordination problem. During a migration, the system needs a clear answer to a basic question: where does this key live right now? If some components use the old mapping and others use the new one, requests can go to the wrong place. Teams often need migration steps that track copied data, redirect reads and writes, and confirm that the new location is ready.

So, the downside isn’t merely that a few records move. It’s that a small change to the shard count can trigger widespread relocation and a fairly involved transition.

Consistent hashing changes the shape of the move

Consistent hashing was designed to reduce how much data changes owners when the cluster changes. A useful way to picture it is a circular map, often called a hash ring.

Both shards and keys are assigned positions on this ring. A key is stored on the next shard found by moving around the ring in one direction. When a new shard joins, it takes responsibility for a nearby slice of the ring. Only the keys in that slice need to move to the new shard.

The ring doesn’t magically eliminate data transfer. Some records still have to be copied, and a production system still needs careful migration logic. But the change is local rather than global: a new shard takes a limited portion of the keyspace instead of changing the destination for nearly every key.

The same idea helps when a shard leaves. Its section of the ring is taken over by neighboring shards, so the system can move the affected records without remapping the entire dataset.

Consistent hashing can also use virtual nodes. Instead of giving each physical machine just one position on the ring, the system gives it many smaller positions. This can make the distribution more even and reduce the chance that one server gets an unusually large share of the work. Think of dividing a long coastline into many small stretches rather than assigning each entire region to one keeper.

The trade-off: simple rules versus flexible growth

Modulo-based sharding isn’t inherently bad. It can work well when the number of shards is stable, the dataset is modest, and simplicity matters more than frequent changes. It can also be suitable when data is easy to rebuild or when a planned migration is acceptable.

Consistent hashing adds its own complexity. Teams must manage the ring, monitor balance, and handle data movement as machines join or leave. If the hash function or routing metadata is handled inconsistently, the system can still send requests to the wrong place. No design removes the need for sound operational planning.

The choice depends on the system’s likely life. A service that expects steady growth or regular server replacement should consider how shard changes will work before data fills every disk. It’s much easier to design for movement early than to discover later that a simple configuration change means relocating a huge share of the database.

A small formula with a large consequence

Simple hash-based sharding assigns each key by taking its hash modulo the shard count. The formula is easy. Its weakness is that changing that count changes the result for many keys.

That can mean substantial data movement when shards are added or removed, along with extra load and migration risk. Consistent hashing limits the disruption by assigning keys and shards to positions on a ring, so topology changes affect a smaller slice of the data.

In distributed systems, a neat rule can hide a big operational bill. Understanding that bill early helps teams choose a sharding strategy that fits not only the system they have today, but the one they may need to run tomorrow.