Codele / System design
Sharding
When one machine cannot hold all the data, split it into pieces called shards. A rule decides which shard each user lives on. Type a name and follow it.
- Sharding splits one big dataset into pieces (shards), each on its own machine.
- A rule picks the shard: the remainder of a number, or a hash of the name. The same name always lands on the same shard.
- A lookup by the key (the user) goes to exactly one shard. The other shards are never bothered.
- A question about everyone, such as a total, must visit every shard and add the answers.
- Changing the number of shards changes the remainder, so many users must move. Plan the split carefully.
Loading the playable lesson…