KatInterview

Pooled Rideshare Dispatch: Matching, Booking and Live Tracking

System DesignModel answer
MediumModel answerSystem Designsystem-designgeospatialconcurrency

Last updated

Design a backend that pools riders into shared vehicles, matches within 2 seconds at 10k requests/s, prevents double-booking, and streams vehicle positions to riders.

Design a Pooled Ride Dispatch Platform

You are building the backend for a ride-hailing product where several riders heading in roughly the same direction can share one vehicle. Describe how you would design it.

What the system must do

  1. Request a ride. A rider submits a pickup point, a drop-off point, and the number of seats needed.
  2. Find a vehicle. The system looks for a vehicle that can take the new rider without pushing any rider already on board past their promised latest arrival time.
  3. Reserve. Seat and vehicle are claimed together as one atomic step. A ride moves through these states: Requested, Matched, PickingUp, EnRoute, DroppedOff.
  4. Live tracking. Riders see their assigned vehicle's position update in real time.
  5. Cancellation. A rider may cancel at any point before drop-off, and the freed capacity must be reusable.

Non-functional targets

  • Speed: a match decision within 2 seconds.
  • Correctness: no seat is ever sold twice, even when several requests race for the same vehicle.
  • Scale: 10,000 ride requests per second and millions of vehicles online.
  • Privacy: exposed location data must follow masking or obfuscation rules.

What to cover in your answer

  • Overall architecture and the communication protocols you pick (for example gRPC, WebSockets, a message bus).
  • How vehicle positions are stored and queried spatially (geohash, H3, quadtree, spatial DB, and so on).
  • The matching logic, including how seat capacity and detour limits are enforced.
  • The data model for ride state and how you handle concurrent bookings.
  • Failure handling and the main trade-offs you made.

Hints

Hint 1

Do the arithmetic first: millions of vehicles reporting every few seconds produces far more writes than 10k ride requests per second. Let that split the design into a heavy tracking path and a smaller, strongly consistent booking path, and shard both by city or region.

Hint 2

Treat matching as a two-stage funnel: a cheap spatial lookup returns a few dozen nearby candidates, then for each one you try inserting the new pickup and drop-off into its existing stop list, checking capacity and every rider's deadline, and only call an exact routing engine on the best few.

Hint 3

The contended object is the vehicle's ordered stop plan. Put a version number on it and commit with a compare-and-set in the same transaction that writes the ride row; on conflict, re-evaluate that vehicle or fall back to the next candidate instead of taking a distributed lock.