Partitioning data for an even workload
What shards store
A replica holds a copy of data; a shard holds its part of the overall dataset. For example, orders from different customers can live on different databases. A request goes to the shard containing the required data. This distributes both storage and work on different records.
The placement rule is called the sharding key. With a customer ID key, all that customer’s records go to one shard. With an individual record ID key, different records of one customer can be placed on different shards.
Where hot shards come from
Equal tenant counts do not imply equal load. One large tenant can send more requests than hundreds of small ones. If all its data is pinned to one database, that becomes a hot shard while others may sit idle.
In this lesson, one customer accounts for 60% of operations. Out of 1,000 operations per second, that is 600. That customer alone exceeds one shard’s limit of 300 operations per second. Adding neighboring shards will not split these 600 while the key remains customer-based.
Why key choice matters
Suppose the large customer has many different records. A record key distributes their processing across shards. This model assumes uniform distribution: with four shards, 800 operations per second become 200 per shard.
Shard selection must always send the same key to the same place. Changing the rule alone therefore cannot split work for one hot record. Here distribution works because the hot group contains many different records. Real key choices must also consider which data is read or changed together.
Distinguishing insufficient capacity from imbalance
First compare individual shard loads. If all are overloaded, capacity is truly insufficient. If one is overloaded while others are free, check the distribution key first. Total spare capacity cannot help that hot shard.
Keep the same shard count, switch the key and compare peak load, failures and completed operations. The model assumes independent operations; it does not calculate migration of existing data or operations across multiple shards.
Task
1,000 operations/s; 60% belong to one large customer. Each shard handles 300 operations/s. Choose shard count and distribution key within budget.
Steady flow over 60s. Customer keys keep the hot group on the first shard; the other 40% spread evenly across all shards, including the first. Record keys spread the group's many distinct records across shards. One identical hot key cannot be split by simple hashing.
- Compare shard loads with tenant-based distribution.
- Add shards from the panel and check whether the hot group stops overloading.
- Explore record-based keys and find a uniform distribution within budget.