Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Ride-Hailing Dispatch and Trip Lifecycle

Design the data model and regional services that match riders with nearby drivers while preserving a single active assignment.

Problem statement

The interview sources name a ride-hailing system and explicitly ask about rider and driver booking flows, concurrent driver acceptance, capacity estimation, Kafka, Redis, client/server state updates across SSE, WebSockets, and push, consistent hashing, surge handling, balancing long versus short trips, and payment idempotency, retries, and failures.

For this exercise, assume riders request point-to-point trips, nearby online drivers may accept time-bounded offers, and the platform tracks each ride through completion or cancellation.

Include a normalized durable data model, live driver location, matching, ride state, a payment attempt tied to the final fare, and order-of-magnitude capacity estimates.

Explain Kafka partitioning, ordering, consumer-group, replay, and backpressure behavior; Redis geospatial/TTL state and recovery; selection among SSE, WebSockets, and push, including fan-out and reconnect or wake-up semantics; where consistent hashing helps or conflicts with spatial locality; and how provider timeouts, callbacks, and retries resolve to one authoritative payment outcome without duplicate charges.

The platform must publish a bounded regional surge multiplier when demand materially exceeds available supply and must avoid indefinite starvation of either short or long trip requests.

A ride may have at most one active assigned driver, a driver may serve at most one active ride, and retries for one logical payment may create at most one successful charge. Exclude driver payouts and regulatory systems.

What to build

  1. A rider can request and cancel a point-to-point ride and observe its authoritative status.
  2. An online driver can publish availability and recent location while offline or stale drivers leave the matchable set.
  3. The platform finds nearby candidates, publishes a bounded regional surge multiplier from current supply and demand, balances offers so neither short nor long trips starve, sends expiring offers, commits at most one active rider-driver assignment, and delivers authoritative lifecycle changes through a justified SSE, WebSocket, push, or hybrid client-update contract to reconnecting clients.
  4. The assigned rider and driver receive ride lifecycle changes through completion or cancellation.
  5. The platform records one authoritative payment outcome for the completed trip fare, handles provider failures or uncertain timeouts, and prevents retries from creating duplicate successful charges.

At scale

  • For this exercise, assume 1 million active drivers across several geographic regions, 3,000 peak ride requests per second, and one driver location update every five seconds while online.
  • For this exercise, target under five seconds p95 from ride request to first viable offer and under ten seconds of location staleness.
  • For this exercise, preserve the single-active-assignment invariant through retries, timeouts, and concurrent driver responses.
  • For this exercise, derive surge and trip-mix balancing signals from rolling regional windows that may be up to one minute stale; damp rapid multiplier changes and bound how long either trip-length class can wait without dispatch consideration.
  • For this exercise, treat the payment provider as an external dependency whose timeout is an unknown outcome until authoritative status or a verified callback resolves it; retries for one idempotency key may yield at most one successful charge.