Replication and Sharding
One database on one machine can break, and it can become too big or too busy. Replication keeps copies of the same data. Sharding splits the data into parts. This lesson shows the difference.
New words
- Replication
- Keeping copies of the same data on different machines.
- Primary and replica
- The primary takes writes. Replicas keep copies and answer reads.
- Failover
- Making a replica the new primary when the old primary breaks.
- Replication lag
- The short delay before a copy gets the newest write.
- Sharding
- Splitting one big database into smaller parts, called shards.
- Shard key
- The field that decides which shard a record goes to.
- Hot shard
- A shard that gets much more work than the others.
What you will learn
- The problem: one notebook for the whole college
- Replication: photocopies of the notebook
- Failover and replication lag
- Sharding: splitting the register
- Uneven shards and cross-shard questions
- Try it: copy or split
- Trade-offs
- In a real system
- Interview tip
- Key takeaways
10 quiz questions at the end.
The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.