All labs
Lab 25
Database Scaling

Read Replicas & Read/Write Split

ChatSphere's feed is read-heavy. One DB chokes; add replicas and reads fan out while the primary takes writes. Then meet the trade-off: replica lag serving a stale read.

ChatSphere's feed is overwhelmingly reads. Split reads onto replicas and the primary stops drowning โ€” then meet the catch: a replica is always a step behind.
1200 reads/s
+ 80 writes/s ยท each node handles 500 q/s
๐Ÿ—„๏ธ Primary ยท reads + writes1280/s ยท 256%
One node, reads + writes โ€” saturated. Reads are starving writes.
The trade-off: replica lag
Primary (truth)
v1
Replica (read)
v1

The write commits to the primary instantly, but the replica needs a moment to copy it. Read too soon and you see the old value. A feed can tolerate this; a payment balance cannot.

What just happened