Design a Nearby Places Search
Our maps app lets people look for places around them: restaurants, pharmacies, petrol stations. We want to design the backend that answers those searches.
This brief is incomplete on purpose, as it would be in a real interview. Ask the interviewer about the users, the features, the targets and the traffic. Whatever you uncover is added below.
- Given a location and a category, the service returns the closest matching places, nearest first.
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- Not uncovered yet
- The search API
- The data model and index for places
- The request path for one nearby search
- The capacity estimate behind your choices
Places are indexed by location with geohashes, S2 cells or a quadtree; a search reads the cells covering its radius including the neighbouring cells across boundaries, and cell size adapts to density so city cells stay small and desert cells large.
Searches are served from an in-memory or read-optimised index sharded by area and replicated per region; candidates are filtered (category, open now, rating) and ranked by true distance only after the cell lookup has bounded them.
When too few results are found, the search widens through rings of cells or coarser cell levels, stopping at 50 km, without rescanning cells it has already read.
Edits are written to a primary store and streamed (change data capture or a queue) to the index builders, meeting the 10-minute freshness target, while search keeps serving from its own copy if editing is down.
15 billion searches a month is about 5,800 a second on average and about 17,000 at peak; 200 million places at around 1 KB is about 200 GB, while the location index alone is a few GB and fits in memory per shard.
Every functional requirement in the brief is visibly served by something on the board, and the non-functional targets are addressed rather than ignored.
Components are labelled, data flows are drawn as connections between them, and the direction of each flow is unambiguous.
Concentrate on finding and ranking places near a location, and on keeping the index up to date. Text search on names, map rendering and turn-by-turn navigation are out of scope.
- Views
- 3