Lesson 7 of 15
44. Design Ride-Hailing with Surge Pricing (Uber / Rapido)

44.6 How are location updates handled?

3 min read+10 XP

Step 5: Deep dives (10 minutes)

As in Chapter 18, at higher volume:

  • Latest position only, in memory: a cell → drivers map (geohash, S2 or H3 cells) per city, plus driver → position, last-seen time and availability. In the chapter's code, a nearby query around the rider returns 38 of 2,000 drivers from neighbouring cells, includes the driver who just moved next to the rider, and skips one whose app went silent 100 seconds ago.
  • Move between cells only when the cell changes; most updates just overwrite a position.
  • Expire silent drivers after ~30 seconds.
  • History to a stream (Kafka), batched, for receipts, analytics and models.
  • Shard by city: a Bengaluru ride never needs Delhi's drivers.

Memory code: "Overwrite the position, move cells rarely, forget the silent."