MentorNode
Start free
Geo, Maps & MarketplacesHarddesign-ride-hailing

Design a Ride-Hailing Service (Uber / Lyft)

Design the matching core: millions of drivers streaming location updates, riders requesting nearby cars, and a dispatch decision that must be made in seconds and never double-assign.

Geospatial IndexingDispatch MatchingLocation StreamingState Machines
Traffic & Capacity Estimates:

5M active drivers · 1M concurrent trips · 600k location updates/second · match in <5s

Functional Requirements

  • •Ingest driver location updates every few seconds and keep a queryable spatial index.
  • •Find candidate drivers near a rider and dispatch the request by ETA and acceptance likelihood.
  • •Manage the trip lifecycle as an explicit state machine through to payment.
  • •Stream live driver position to the rider's map during pickup and the trip.

Non-Functional Requirements

  • •Nearby-driver query under 100ms at p99.
  • •A driver must never be assigned to two trips — matching is a critical section.
  • •The system must keep dispatching during a regional surge, degrading match quality rather than failing.

Back-of-the-Envelope Math

  • 5M drivers updating every 4s = 1.25M writes/second of location data, almost all of it immediately overwritten.
  • Location history at 1.25M/s * 50 bytes = 62 MB/s if retained — retention policy is a real cost decision.

Key Architectural Trade-offs

  • Geohash/S2/H3 cell indexing (cheap, cell-boundary edge cases) vs a quadtree (precise, rebalancing cost under movement) — both beat a naive distance scan.
  • Live locations belong in memory, not in the durable store; the durable trip record and the ephemeral position stream have opposite requirements.
  • Optimistic dispatch to several drivers at once fills cars faster and creates race conditions that need a lock or a conditional write to settle.

Click or drag a component onto the canvas, then connect the handles to draw the data flow.

3 nodes · 2 edges

Components · 35

Client & Edge4
Compute & Gateway7
Storage & Caching11
Messaging & Streaming6
Coordination & Ops5
Intelligence2
Canvas overview