Chapter 5 of 10All chapters
Chapter 5 of 10
Data at scale
Replicas, sharding and their costs.
Replication
Read replicas copy the primary and serve reads, which spreads load. They lag behind by milliseconds to seconds, so a user can write and then not see their own change.
- Route reads that must be current to the primary.
- Failover promotes a replica, and doing it automatically is harder than it looks.
Sharding
Splitting data across machines by key removes the single-machine limit and makes cross-shard queries and transactions painful. Postpone it as long as honestly possible.