System Design Proximity Service: Interview Talk Track

System Design Proximity Service: Interview Talk Track

"Design a service that finds nearby restaurants" is a classic system design prompt. It tests whether you can turn a fuzzy product idea into requirements, pick a spatial indexing approach, and scale a read-heavy system. You don't need to memorize a reference answer; you need a clean structure and clear trade-offs.

This system design proximity service interview talk track gives you a 45-minute outline.

1. Clarify requirements (about 5 minutes)

Ask questions that shape the design:

A good default scope: static businesses, search by location and radius (for example up to 20 km), return the top results sorted by distance with basic filters, and new or edited businesses can appear within minutes rather than instantly.

Non-functional: low latency for searches, high availability, and a heavily read-dominated workload.

2. Back-of-the-envelope estimates (about 3 minutes)

State assumptions out loud. With many millions of businesses, the data itself is modest: an ID, latitude, longitude, and a few fields per business fits comfortably in memory on a few machines. The real load is search traffic, which can be thousands of queries per second at peak. That tells you the design should optimize reads and caching, not writes.

3. API sketch

4. High-level design (about 8 minutes)

Flow: the client sends its location; the search service finds candidate IDs nearby, filters and ranks them, and the client fetches details, often from cache.

5. Deep dive: spatial indexing (about 12 minutes)

Scanning every business and computing distance doesn't scale. Explain why a simple latitude and longitude range query is awkward: a database index on two separate columns isn't efficient for 2D range searches.

Option 1: Geohash. Encode each location as a string where a shared prefix means nearby areas. Longer strings mean smaller cells. To search, compute the geohash of the user's location at a precision matching the radius, then query that cell plus its eight neighbors. Neighbors matter because a nearby business can sit just across a cell boundary.

Pros: simple, works with ordinary indexes on a string column, and easy to shard by prefix. Cons: cells are fixed in size, so dense cities produce crowded cells while rural cells sit nearly empty.

Option 2: Quadtree. Recursively split the map into four quadrants until each leaf holds at most some number of businesses. Dense areas get deeper trees with small cells; sparse areas stay shallow.

Pros: adapts to density. Cons: it's an in-memory structure you must build and rebuild, and updates are more complex.

Other options worth naming: Google's S2 cells and Uber's H3 hexagons are hierarchical grids used in real systems; many databases also offer geospatial indexes.

A good talk track: "For mostly static businesses, I'd start with geohash because it's simple and shards well. If density imbalance becomes a problem, a quadtree or variable precision helps."

6. Ranking and filtering

After finding candidates, compute precise distance, apply filters like category or open now, and sort. If the radius returns too few results, expand to a coarser precision or a larger search area. If it returns too many, limit candidates per cell before ranking.

7. Scaling reads

8. Handling updates

Business edits go to the primary database. A background job or change stream updates the spatial index, which explains why freshness within minutes is acceptable. If the interviewer pushes toward moving objects like drivers, switch approaches: store live locations in an in-memory store keyed by cell, accept frequent overwrites, and expire stale entries.

9. Wrap up with trade-offs

Summarize: geohash for a simple, shardable index; neighbor-cell search to avoid boundary misses; heavy caching and replication for a read-dominated load; and asynchronous index updates for business edits. Name a risk, such as crowded cells in dense cities, and your mitigation.

Practice it out loud

The structure is easy to read and harder to deliver smoothly in 45 minutes. Rehearse with a timer until requirements, the indexing deep dive, and trade-offs flow naturally.

Luna Interview is a practice and calm-under-pressure companion for that kind of rehearsal, with timed sessions and structured prompts in your browser. Try Luna Interview at https://lunainterview.xyz/.