AlgoMaster Logo

Handling Location Data

High Priority36 min readUpdated June 17, 2026
AI Mock Interview

Practice this topic in a realistic system design interview

Consider a ride-sharing app like Uber. A user opens the app looking for the nearest available driver. There are 100,000 active drivers in the city. How do you find the 10 closest ones in under 100 milliseconds?

The naive approach is straightforward: calculate the distance from the user to every single driver and return the closest 10. With 100,000 drivers, that means 100,000 distance calculations per request. At 1,000 requests per second, the system performs 100 million calculations per second. This does not scale.

Adding a database index does not solve this. Traditional B-tree indexes work on one dimension at a time. They can efficiently answer "find all users with age > 25" but struggle with "find all drivers within 2km" because location has two dimensions that must be queried together.

This is the core challenge of location data. It shows up in ride-sharing, food delivery, dating apps, and real estate search, where nearby queries need a different access pattern from ordinary single-column lookups.

A strong interview answer uses a two-step shape: generate a small set of nearby candidates, then rank those candidates with exact distance, ETA, availability, or business rules.

These techniques appear in many system design interviews:

  • Design Uber - Finding nearest drivers
  • Design Yelp / Nearby Places - Proximity search for businesses
  • Design Tinder / Dating App - Matching users by location
  • Design Airbnb - Finding nearby listings
  • Design DoorDash / Food Delivery - Matching orders with nearby drivers
  • Design Google Maps - Route planning and place search

Interview Answer Shape

In an interview, keep the shape simple:

  1. Clarify the query: nearest N, radius search, polygon containment, route-aware ETA, or analytics.
  2. Generate candidates with a spatial index or cell system instead of scanning every point.
  3. Post-filter and rank candidates using exact distance, ETA, availability, or business rules.
  4. Choose storage based on update rate and query complexity: PostGIS/MongoDB for durable geo queries, Redis Geo for hot real-time matching, Elasticsearch for text plus geo search.
  5. Mention edge cases: latitude/longitude order, geohash cell boundaries, stale locations, and high update frequency.

Why Is Location Data Challenging?

Premium Content

This content is for premium members only.