← All lessons

Question breakdowns

Design a ride-hailing backend

Riders request, drivers move, and a match has to happen in seconds against a map that changes every few seconds. The interview is location indexing, matching without double-booking, and a trip state machine that survives flaky phones.

28 min readUpdated November 2026Premium

“Design Uber” is one of the most common senior system design questions because it has a bit of everything: a firehose of writes (driver locations), a geospatial query under a latency budget (nearby drivers), a concurrency problem with real consequences (one driver, two riders), and a long-running workflow on unreliable clients (the trip).

The trap is spending forty minutes on boxes and arrows. The interviewer is waiting for three deep dives, and this breakdown is organised around them.

Requirements

Pin these down in the first five minutes; they change the design.

Functional

Non-functional

Out of scope unless asked: surge pricing models, routing/ETA engine internals, driver onboarding, ratings. Name them, park them.

The point

Say the split out loud: location is high-volume, ephemeral and can be stale; trips are low-volume, durable and must be correct. They want different storage, and saying so in minute five frames the whole design.

Back-of-the-envelope

Location writes dominate by two orders of magnitude, and nobody needs yesterday’s driver positions in the hot path. That rules out writing every ping to a relational database.

API

POST /v1/drivers/me/location        {lat, lng, heading, ts}          -- every ~4 s, from the driver app
GET  /v1/drivers/nearby?lat=&lng=   → [{driver_id, lat, lng, eta}]   -- rider app, while browsing
POST /v1/trips                      {pickup, dropoff, product}       → {trip_id, status: "matching"}
POST /v1/trips/{id}/accept          (driver)                         → 200 or 409 if already taken
POST /v1/trips/{id}/events          {type: "arrived" | "started" | "completed", ts}
GET  /v1/trips/{id}                 → current state, both locations

Location updates go over a persistent connection (WebSocket or MQTT) rather than individual HTTP requests in practice — 250,000 TLS handshakes a second is avoidable cost — and the server pushes trip offers and live updates back over the same connection.

High-level design

 Driver app ──ws──▶ Location service ──▶ Geo index (Redis, sharded by city/cell)
     ▲                     │
     │                     └──▶ Kafka: location stream ──▶ trip tracking, analytics
     │
 Rider app ──▶ API gateway ──▶ Trip service ──▶ Postgres (trips, state machine)
                                   │
                                   └──▶ Matching service ──▶ Geo index (nearby query)
                                                 │
                                                 └──▶ offer to driver ──ws──▶ Driver app

The members’ section takes the three deep dives — the geo index, matching without double-booking, and the trip state machine — and the failure modes.

Premium

The rest of this lesson is ₹1

Geospatial indexing with geohash and H3, matching without double-booking, the trip state machine and flaky phones, live tracking fan-out, multi-city partitioning, failure modes, and the follow-ups.

PhonePe, Google Pay, Paytm or any UPI app. Cards and net banking work too. One payment unlocks this lesson on this device.