Code RoomDatabase connection pooling proxy
MediumPrep Room Coding #3760

Database connection pooling proxy

System designNetworking & APIsMid–Senior~40 min

Design a connection-pooling proxy that sits in front of a primary Postgres cluster to protect it from connection exhaustion. The app fleet is 1,500 stateless servers that would otherwise each open 20+ DB connections (30k+), but the database can only handle ~2,000 backend connections. The proxy must multiplex many client connections onto a small pool, keep p99 added latency under 1ms, handle transaction integrity, and drain/rebalance pools during a database failover without breaking in-flight transactions. Walk through the pooling model, the multiplexing strategy, and the core trade-off.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts (data model, bottlenecks, consistency, failure modes) and name the trade-offs you are making.

Clarify4:30 left
Estimate4:30 planned
Design13:30 planned
Deep dive10:30 planned
Failure7:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.