SDE & MLE Prep

Proximity Service (Yelp / Nearby Places)

Requirements: find businesses within radius r of a location, filter/sort by distance & rating; 100 M places; read-heavy (~5k QPS reads, rare writes).

client -> LB -> search svc -> geo index (read replicas, in memory)
                                   geohash prefix "9q8yy" -> [place ids]
                           -> place details cache -> places DB (sharded by place_id)
business owners -> business svc -> places DB -> (async, nightly or CDC) -> rebuild geo index

Deep dives

  • Geohash: interleave lat/lng bits into a base32 string; shared prefix ≈ nearby. Query the cell + its 8 neighbours (handles boundary effects); choose precision from the radius.
  • Quadtree: recursively split cells with > K places; good for uneven density; built in memory at startup.
  • Google S2 / Uber H3: hierarchical cells on a sphere; region coverings for arbitrary shapes.
  • Index is small (100 M × ~24 B ≈ a few GB) → fits in memory; replicate for reads; writes can be eventually consistent.
  • Ranking: distance + rating + popularity + personalization.