Stage 2 · Lesson 8 of 10
Choosing shard keys, hot spots and resharding
A good has many different values, spreads load evenly and matches how data is read. Even so, one shard can run hot. A celebrity account or a trending hashtag sends all its traffic to one key.
You can split a hot key across several partitions by adding a random suffix to it, or cache its reads. Data also grows unevenly, so plan for , moving data between shards, from day one. With hash(key) mod N, changing the number of shards N moves almost every key.
Two layouts avoid that. You can create many small logical partitions and assign them to physical servers, or you can use . Either way, you move only a slice of the data.
Resharding a live system usually means (writing to the old and new places at once) or copying with , then switching over.
Common trapchoosing the key from the write path and ignoring the reads.
A question to check yourself, an AI practice session and 3 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Database Fundamentals for Tech Interviews
Design Gurus · Beginner · Subscription
Storage engines, indexes, transactions, isolation, replication, sharding and NoSQL models
- GitHub repoFreeSystem Design Interview Roadmap by karanpratapsingh
Karan Pratap Singh · Intermediate
Free: the databases, indexes, normalisation, ACID, sharding and replication chapters