In hash-based sharding, what happens when the shard count changes?

Test your Systems Design Concepts knowledge with our comprehensive quiz. Utilize flashcards and multiple choice questions to enhance your study session. Prepare thoroughly with detailed explanations for each answer and ace your examination!

Multiple Choice

In hash-based sharding, what happens when the shard count changes?

Explanation:
Hash-based sharding assigns each key to a shard by computing hash(key) mod N, where N is the number of shards. When the shard count changes, that modulo divisor changes, so the resulting shard for most keys is different. As a result, many keys must be moved to rebalance across the new set of shards. In plain hash-based sharding this is expected behavior. If you wanted to avoid moving most data, you’d use a different approach (like consistent hashing or virtual nodes) that minimizes redistribution when shards are added or removed. This is why changing the shard count leads to the modulo changing and most data needing to be moved.

Hash-based sharding assigns each key to a shard by computing hash(key) mod N, where N is the number of shards. When the shard count changes, that modulo divisor changes, so the resulting shard for most keys is different. As a result, many keys must be moved to rebalance across the new set of shards. In plain hash-based sharding this is expected behavior. If you wanted to avoid moving most data, you’d use a different approach (like consistent hashing or virtual nodes) that minimizes redistribution when shards are added or removed. This is why changing the shard count leads to the modulo changing and most data needing to be moved.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy