Code RoomQuery batching layer
MediumPrep Room Coding #3186

Query batching layer

System designDistributed systemsMid–Senior~35 min

Design a batching/coalescing layer in front of a downstream data store to fix an N+1 query explosion: a GraphQL/page-render layer issues thousands of single-key lookups (getUser(id)) per request burst, and each becomes its own round trip, saturating the database. Design a layer that automatically batches concurrent single-key reads into multi-key fetches and deduplicates repeated keys, without the callers changing their code much.

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:00 left
Estimate4:00 planned
Design11:30 planned
Deep dive9:30 planned
Failure6:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.