Skip to main content
Common Designschapter 8 of 8 · 4 lessons

Proximity Service (Yelp, Nearby)

Find businesses within a radius, ranked by distance, over hundreds of millions of rows.

Proximity search is the interview question that looks small and is not. Find restaurants within 5 km, nearest first.

The geospatial index is the hard part everybody expects. What separates a junior answer from a senior one is everything around it: how the data gets split across machines, how it stays fresh, and what happens in Manhattan.

Lessons

4 in this chapter
  1. Sizing the ProblemEstimate first, because the numbers rule out most of the designs.2 min
  2. The Read PathTap to ranked list: nine cell lookups, one distance pass, one sort.2 min
  3. Splitting Reads from WritesA 20,000 to 1 ratio means the two paths should not share a table.2 min
  4. Density and HotspotsPopulation is not uniform, so a uniform grid shards badly.3 min