A maps app lets people search for places near them: 'coffee within 1 km', 'open restaurants near me'. There are 100 million places worldwide, and owners add or edit about 50,000 places a day. At lunchtime peak the app serves 30,000 nearby searches per second, each with a location, a radius between 500 m and 20 km, and optional filters such as category, rating and opening hours. Results must appear in under 200 ms, sorted by a mix of distance and rating. A newly added place may take a few minutes to appear in searches.
Functional requirements
Return places within a given radius of a latitude and longitude
Filter by category, minimum rating and 'open now'
Sort results by distance, rating or relevance, with pagination
Show a place's details page with photos and reviews
Let owners add and edit places
Non-functional requirements
Nearby searches return in under 200 ms at p95
Search stays available during regional failures; slightly stale results are acceptable
Edits appear in search results within 5 minutes
Constraints and scale
100 million places, about 1 KB of searchable data each
30,000 nearby searches per second at peak
50,000 place edits per day (read to write ratio well above 1,000:1)
You will practise
Index two-dimensional locations with geohashes, quadtrees or a geospatial index
Handle cell boundaries and dense versus sparse areas correctly
Separate a read-optimised search index from the system of record
Show 3 hints
A geohash prefix gives you a grid cell. Which neighbouring cells must you also check, and why?
Central London and rural Scotland have very different place densities. Should every cell be the same size?
Writes are rare. Could the index be rebuilt or updated asynchronously?