Read-replica routing layer
Your task
Design a read-replica and routing layer in front of a Postgres primary with 6 read replicas, handling a 95/5 read/write ratio at 100k QPS. Routing must send writes to the primary, spread reads across healthy replicas, and avoid the 'read-your-own-write' bug where a user updates a profile and immediately sees stale data. How do you route, track replica health, and handle replication lag?
It covers
- Read write split
- Replica lag
- Load balancing