Design a system to search for nearby places like Google Maps' "restaurants near me" feature. Users provide their coordinates and a search radius (e.g., 1-50 km), and the system returns places matching optional filters (category, rating, price range) sorted by distance or relevance. The system stores 2 billion places globally, handles 100,000 search queries per second, and must return results within 100ms. Places are added or updated by business owners and third-party data feeds.
In your 90-second answer, cover: - Spatial indexing strategy for efficient proximity queries on 2 billion places - Query processing: how a "restaurants within 5 km" query is evaluated - How you combine spatial proximity with attribute filtering (category, rating) - Geographic sharding and global distribution for low-latency serving
Constraints: the system must handle both dense areas (Manhattan: 50,000 places per km^2) and sparse areas (rural: 1 place per 100 km^2). Adding a new place must be searchable within 60 seconds.
How to approach it
- Hint 1
The key challenge is converting a 2D proximity problem into something that can be indexed linearly. Geohashing maps (lat, lng) to a 1D string where nearby points share a common prefix -- this lets you use standard B-tree or key-value indices for spatial queries.
- Hint 2
A fixed geohash precision does not work everywhere: in Manhattan you need fine-grained cells (precision 7: ~150m), but in rural Montana a coarser cell (precision 5: ~5km) suffices. Consider adaptive precision or a hierarchical structure like a QuadTree that subdivides dense areas more finely.
- Hint 3
When searching near a geohash cell boundary, nearby places may be in an adjacent cell. You must query the target cell AND its 8 neighboring cells to avoid missing results at boundaries -- this is the most common geospatial search bug.
Ready to answer it out loud?
Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.
Practising needs an invite code. Join the waitlist and we’ll send you one.