Database Replication & Sharding
Scale databases with replication and sharding, choosing schemes whose lag, rebalancing and cross-shard costs the product can live with.
4 objectives 6 steps about 140 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Compare synchronous and asynchronous replication and single-leader (read replicas), multi-leader and leaderless topologies by write path, failover behavior and conflict handling.
- Explain replication-lag anomalies on read replicas (stale reads, non-monotonic reads, lost read-your-writes) and choose mitigations.
- Choose a shard key and strategy (range, hash, directory) that avoids hot partitions and serves the main queries.
- Plan rebalancing and resharding, and serve cross-shard queries with index tables or materialized views while estimating the cost of cross-shard joins and transactions.
Lesson plan
6 steps, about 140 min · 5 of 5 lessons available so far
- Leaders, read replicas, sync versus async replication and failover Concept · 20 min
- Multi-leader and leaderless quorums Concept · 20 min
- Observing replication lag with a read replica Lab · 25 min
- Shard keys, hot spots, index tables and materialized views Concept · 30 min
- Sharding a social graph table and planning a rebalance Worked example · 30 min
- Replication and sharding check Knowledge check · 8 questions
Practise it
Run a primary with one replica (for example PostgreSQL in containers), reproduce a read-your-writes violation under induced lag and fix it by routing recent writers to the primary; then write a shard-key proposal for a 5 TB table with hot-key analysis and a resharding plan.
References
Hard prerequisites
None.
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.