Data & storage / 4 / 11
Database replication
A profile service outgrows one database. We add read replicas, meet replication lag and the read-your-writes problem, lose the leader, fail over, and decide what synchronous replication is worth.
- 13 min
- Intermediate
- 10 steps
- Request p95
- 850 ms
- Worst replica lag
- 0 ms
- Stale reads
- 0 %
- Commits lost on failover
- 0
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Profile API → DB ARequest
SELECT name, bio FROM profiles
WHERE user_id = 'u_42';1
Response
(1 row)
Time: 640.2 ms2
user_id— A primary-key lookup. Cheap on its own, slow when the server is saturated.Time— 640 ms for one row: the time is spent waiting for CPU and disk, not on the query.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes