Nearby drivers query

DesignHard50 minUber and DoorDash style

Your task

Design a 'nearby drivers' query service where both the queried set (drivers) and the queriers (riders) are constantly moving. A rider opening the app needs the ~20 nearest available drivers, ranked by ETA not raw distance, returned in <50ms, while 300k drivers update their location every 4 seconds. Unlike a static POI search, the index is being rewritten constantly. Describe the dynamic spatial index, how you serve k-NN under continuous churn, how you rank by ETA, and the consistency trade-off between index freshness and query latency.

It covers

  • Moving objects
  • Knn
  • Dynamic index