← Back to practice catalog

System design interview guide

Design Uber

TL;DR:

It's Friday night and you tap Request a ride, expecting the app to find one free driver who can reach you soon even though drivers keep moving through the city. The painful failure is when the wait looks like three minutes and then jumps to twelve, because the app was still using an old location for that driver.

Overview diagram for Design Uber

Problem statement

You're designing a ride-sharing marketplace: riders request trips, the system finds nearby available drivers, tracks live location, computes fare (distance, time, surge), and moves each trip through a clear state machine to completion.

Constraints in plain language. Functionally: request with pickup/dropoff, match within seconds, track driver en route, surge-aware pricing, payment after ride, ratings. Non-functionally: < 5 s to first match offer, 99.99% availability on the safety-critical path, location updates every few seconds, millions of concurrent sessions. Scale: 100M users, ~20M rides/day, peak ~500 rides/s, and ~250K location updates/s—so geospatial indexing and the location write path dominate.

What interviewers reward: geospatial query strategy, atomic matching, location pipeline, ride state, and honest surge/failure behavior—not a generic "microservices + database" diagram.

Introduction

Friday night. You open the ride app, set pickup, and tap Request. The product promise is simple: find one free driver who can reach you soon, show that driver moving toward you, and keep the status honest until you get out at the destination.

The painful failure is not “no cars in the city.” It is a wait that looked like three minutes and then jumped to twelve because the app was still using an old GPS point. Interviewers want that story: matching is a race against stale location, not a generic microservices diagram.

This guide walks one ride from request to completion. You will index drivers so “nearby” is cheap, keep location writes off the match hot path, make Accept atomic so two drivers cannot both win, and say what the rider sees when supply is thin.

How to approach

Do not open with Kafka. Open with the product path.

  1. Scope the ride loop. Request with pickup and drop-off, match a free driver, track to pickup, trip, complete or cancel. Payments and ratings stay thin unless the interviewer asks.
  2. Name the hard constraints out loud. Match offer in a few seconds. Location used for ETA no more than a few seconds old. One Accept wins. One city failing should not take the others down.
  3. Draw one write path and one read path. Location updates are the heavy write. Matching is a short read-then-decide path that must not wait on analytics.
  4. Deep-dive one fight. Usually geospatial query strategy or atomic accept. Leave surge as a short, honest zone multiplier story.
  5. Close with failure. No drivers nearby, stale location, driver cancel mid-trip, New Year’s Eve overload.

In the room: “I will optimize for match latency and honest ETA first. I will accept eventual consistency on the last GPS point, and strong consistency on who owns the ride.”

Capacity estimation

Use the numbers as a story about where the system hurts—not as memorization.

SignalRough estimateWhat it implies
Registered users~100MAccount and history are large, but not the match hot path
Daily active~10MPeak is neighborhood-local, not uniform
Rides / day~20M~230 rides/s average; peak ~500 ride requests/s
Location updates~250K/sDominates writes; must be sharded by region
Match SLAfirst offer < 5sMatching cannot wait on cold storage or full-fleet scan

Implications:

  • Location ingestion needs its own scale story (region shards, in-memory latest position).
  • Matching should query a small candidate set, not every driver in the city.
  • Accept must be cheap and correct under concurrent taps.
  • Analytics and receipts can lag; the map pin cannot.

Design decisions

DecisionChoiceWhyCost
Nearby searchGeohash / S2 / H3 cells + expand neighborsBounds the scanCell edges and hot downtown cells
Latest locationFast store keyed by driver_id (Redis / memory shard)Match needs fresh pointsHistory must be async if you keep it
AcceptConditional update on ride rowOnly one driver winsNeed clear retry / “taken” UX
Routing / ETAExternal routing APIDo not rebuild maps in 45 minutesDependency latency and cost
SurgeZone demand/supply multiplier in cacheExplains Friday-night pricingFairness vs smoothness

High-level architecture

[ Rider app ] ---- request / track ----> [ API / Gateway ]
[ Driver app ] -- location + accept ---> [ API / Gateway ]
                                              |
                    +-------------------------+-------------------------+
                    |                         |                         |
              [ Matching ]              [ Location ]              [ Ride state ]
               query cells               ingest GPS               state machine
               rank ETA                  latest pos               atomic accept
                    |                         |                         |
              [ Geo index ]            [ Hot location ]           [ Ride DB ]
              (cells→drivers)           (Redis/memory)            (region shard)
                    |
              [ Routing API ]  (ETA / polyline — out of core ownership)
                    |
              [ Surge / fare ]  (zone multiplier cache → quote)
                    |
              [ Async: payments, receipts, ratings, analytics ]

Who owns what. Matching owns candidate selection and offers. Location owns freshness. Ride state owns who is assigned. Surge/fare owns the quote. Routing is a dependency you call, not a subsystem you invent on the board.

In the interview: narrate one request left-to-right, then say location writes are a separate firehose that never blocks Accept.

Detailed design

Write path — driver location

  1. Driver app sends GPS every few seconds to a regional ingestion endpoint.
  2. Ingestion writes latest position for driver_id (and availability flag) into a hot store.
  3. Optionally enqueue history for analytics—not on the match path.
  4. If the point is older than a TTL when read for matching, treat the driver as stale and skip or re-query.

Write path — request and accept

  1. Rider creates a ride in requested with pickup, drop-off, and an idempotency key.
  2. Matching loads nearby available drivers from geo cells around pickup, ranks by ETA, and offers.
  3. Driver taps Accept. Server runs a conditional update: ride still requested and unassigned → set driver and accepted. Losers get “ride taken.”
  4. Later transitions (en route, in progress, completed, cancelled) are server-authoritative; apps follow via push or poll.

Read path — rider tracking

  1. After accept, rider UI needs driver position and ETA.
  2. Serve latest driver point from the hot store; call routing for ETA/polyline as needed.
  3. Prefer push (WebSocket/SSE) for map updates; polling works if you name battery and server cost.

Deep dive: nearby matching

The interview fight is almost always “how do you find nearby drivers without scanning the fleet?”

  • Partition the map into cells. Each available driver is indexed under the cell of their latest point.
  • On request, query the pickup cell and a ring of neighbors, filter available, drop stale TTLs, rank by distance or ETA, cap to top N.
  • If the set is empty, expand radius once or twice, then tell the rider honestly: no cars nearby / longer wait—not a fake three-minute pin.
  • Offer strategy: sequential offers to top drivers, or a short broadcast where first atomic accept wins. Say which you prefer and why (driver spam vs match latency).

Key challenges

  • Stale GPS makes ETAs lie; freshness TTL is part of the product.
  • Hot downtown cells create write and query skew; region shards and cell splits matter.
  • Double accept without a conditional update assigns two drivers to one rider.
  • Surge without a clear zone window feels random to riders and unfair to drivers.
  • Peak events (NYE) saturate matching and location ingestion together.

Scaling the system

  • Shard matching and location by city/region so one metro’s spike does not take down another.
  • Keep location ingestion autoscaled separately from match workers.
  • Split a single hot geo cell when one neighborhood owns too much of the index.
  • Rate-limit or queue new requests when the match pool is saturated; keep in-trip tracking up first.
  • Cache surge multipliers per zone; recompute on a short window, not on every GPS tick.

Failure handling

FailureWhat the user seesWhat the system does
No drivers in radiusHonest wait or “try again”Expand once, then stop lying about ETA
Driver goes offline after acceptRe-match or cancel with policyState machine timeout + new offer
Matching slowDelayed offerTimeout, widen radius, or degrade new requests
Location store blipMap freezes brieflyRetry read; do not invent motion
Routing API downRough distance ETAFallback heuristic; say it is degraded

API design

Hottest calls:

APIPurpose
POST /ridesCreate request (idempotency key)
POST /rides/{id}/acceptDriver accept (conditional)
POST /drivers/me/locationGPS ingest
GET /rides/{id}Status + assigned driver
GET /rides/{id}/trackingLatest point + ETA

Example list/query shape for matching internals (not always a public API): cell, radius_m, available=true, max_candidates.

Rider                API               Match              Ride DB            Driver
  |-- POST /rides --->|                  |                   |                  |
  |                   |-- find nearby -->|                   |                  |
  |                   |<-- candidates ---|                   |                  |
  |                   |-- create ride ---------------------->|                  |
  |                   |-- offer ----------------------------|------------------>|
  |                   |                  |                   |<-- Accept -------|
  |                   |                  |                   | CAS requested→accepted
  |<-- assigned ------|                  |                   |                  |

Green Dashboard. Angry Users. The Production Mindset System Design Interviews Expect.

Dashboards can be green while riders rage. The classic case: match success rate looks fine, but time-to-pickup blew up because half the “available” drivers had GPS older than thirty seconds.

What it looks like. Support tickets say “pin jumped.” ETA flipped from three minutes to twelve. Accept rate is still healthy because drivers who are actually close do accept—after the damage.

Why it happens. Matching ranked on stale points. The location pipeline was healthy on write QPS, so nobody looked at age of point used at match time.

What good teams do. Track stale-location rate at match, p99 match latency, time-to-first-offer, and accept-after-offer. Alert when the location age at match crosses the product TTL. Prefer skipping a stale driver over a pretty but wrong pin.

How to use this in an interview. Pick one war story: stale GPS → angry ETA → measure location age at match → skip or re-query. One failure, one metric, one fix.

Bottlenecks and tradeoffs

  • Freshness vs battery: more GPS uploads improve ETA and burn phone and backend.
  • Broadcast offers vs sequential: faster fill vs driver notification spam.
  • Strong consistency on every GPS point is usually the wrong fight; strong consistency on Accept is the right one.
  • Building your own router eats the interview; integrating a routing API is the senior move.

Interview tips

You might say: “I will keep latest driver location in a regional hot store and index available drivers by geo cell so nearby search stays bounded.”

Interview Push: “What if two drivers accept at once?”

Land here: “Accept is a compare-and-set on the ride row. One writer wins; the other gets ride taken. Retries use the same accept idempotency key.”

You might say: “Surge is a zone multiplier from recent demand versus available drivers, read at quote time.”

Interview Push: “Is location strongly consistent?”

Land here: “Last-write-wins with a freshness TTL for matching. The ride assignment is strongly consistent. I will not pretend every GPS tick is a distributed transaction.”

What should stick

  1. Nearby search is a bounded geo query, not a full fleet scan.
  2. Location is a firehose; matching is a short decision on fresh-enough points.
  3. Accept must be atomic.
  4. Surge is a zone supply/demand story, not a random multiplier.
  5. Honest degradation beats a fake three-minute pin.

Key Takeaways

  • Start from one ride path: request → match → track → complete.
  • Geo cells + hot latest position + atomic accept are the core trio.
  • Measure location age at match, not only write QPS.
  • Keep payments, ratings, and deep map-building out of the critical path unless asked.

Quick revision notes

The problem in your own words. A ride app must find one free driver who can reach you soon, keep that driver’s location honest, and let only one Accept win.

The design in one breath. Index available drivers by geo cell, keep latest GPS in a regional hot store, match from nearby cells, and assign with a conditional update on the ride row. Surge is a zone multiplier. Routing is a dependency.

The choices you must defend. Cell search vs full scan. Eventual freshness on GPS vs strong Accept. Broadcast vs sequential offer. External router vs building maps.

The mistakes that cost points. Scanning the whole fleet, putting analytics on the location hot path, non-atomic Accept, and fake ETAs from stale pins.

What interviewers expect

Interviewers are not checking whether you named Kafka. They check whether you can walk one ride request from tap to matched driver with honest latency and failure behavior.

Scope first Clarify rider request, driver availability, real-time tracking, fare estimate, and post-ride payment at a high level—not building Google Maps or a card processor from scratch.

Matching and geospatial index Name how you find nearby available drivers (geohash grid, S2/H3 cells, quadtree, or geospatial DB). Say query pattern: pre-filter by cell, rank by distance/ETA, cap candidates. Mention stale location TTL and re-query if driver moved.

Ride state and concurrency Explicit states: requested, offered, accepted, arrived, in-progress, completed, cancelled. Atomic accept (compare-and-set on ride row or distributed lock) so only one driver wins. Idempotent request ride from client retries.

Location pipeline Drivers push location every N seconds; ingestion must not block matching. Separate hot recent position (Redis/memory per driver) from history (optional analytics). Say write rate at peak and how you partition by region.

Surge and pricing (brief) Demand/supply ratio per geo cell or zone; precomputed multipliers vs real-time. Tradeoff: smooth UX vs driver/rider fairness.

Failure and degradation No drivers nearby → honest ETA/retry. Matching service slow → timeout and expand radius vs cancel. Driver goes offline mid-ride → state reconciliation.

Observability Match latency p99, time-to-first-offer, accept rate, stale-location rate, surge multiplier distribution—not just "rides completed."

Interview workflow (template)

  1. Clarify requirements. Confirm functional scope, users, consistency needs, and which non-functional goals matter most (latency, availability, cost).
  2. Rough capacity. Estimate QPS, storage, and bandwidth so your data model and partitioning story are grounded.
  3. APIs and core flows. Define a minimal API and walk 1–2 critical read/write paths end to end.
  4. Data model and storage. Choose stores for each access pattern; call out hot keys, indexes, and retention.
  5. Scale and failure. Add caching, sharding, replication, queues, or fan-out as needed; say what breaks in failure modes.
  6. Tradeoffs. Name alternatives you rejected and why (e.g. strong vs eventual consistency, sync vs async).

Frequently asked follow-ups

  • How do you find nearby drivers efficiently at scale?
  • How do you handle real-time location updates from millions of drivers?
  • How do you prevent two drivers from accepting the same ride?
  • How does surge pricing work and where do you compute it?
  • What happens when no drivers are available in the area?

Deep-dive questions and strong answer outlines

How do you match a rider to a nearby driver?

Index driver locations in a geospatial structure (geohash/S2/H3 cells or Redis GEO / PostGIS). On request, query drivers in expanding radius or adjacent cells who are available. Rank by ETA/distance, offer to top N drivers sequentially or broadcast with first atomic accept wins. Re-query if locations are stale beyond a TTL.

How do you store and update driver locations at scale?

Drivers send GPS every few seconds to a regional ingestion layer. Write latest position to a fast store keyed by driver_id (Redis, in-memory shard). Partition by city/region to limit fan-out. Optional async archive for analytics—not on the match hot path.

How do you prevent double-assignment of a ride?

Ride row has status + assigned_driver_id. Accept is a conditional update (status=requested → accepted AND driver_id=null). Only one driver succeeds; others get "ride taken." Use idempotency keys on accept API for retries.

How does surge pricing fit into the architecture?

Aggregate demand (requests) and supply (available drivers) per zone on a short window. Compute multiplier stored in cache; fare service reads multiplier at quote time. Precompute on schedule for stability or update in real time for accuracy—state tradeoff.

What is the ride state machine?

requested → matched/accepted → driver_en_route → in_progress → completed (or cancelled at defined points). Each transition is server-authoritative; clients display UI from poll/WebSocket push. Timeouts for no-show and driver cancel with policy.

How do you handle peak load on New Year's Eve?

Regional sharding of matching, queue or rate-limit new requests if match pool saturated, surge to balance supply, degrade non-critical features (history, promos). Scale location ingestion separately from match workers.

AI feedback on your design

After a practice session, InterviewCrafted summarizes strengths, gaps, and interviewer-style expectations—similar to a written debrief. See a static example report, then practice this problem to get feedback on your own answer.

FAQs

Q: Do I need to design the full map/routing engine?

A: No—integrate with a routing API (OSRM, Google) for ETA and route polyline. Focus on matching, location freshness, and ride lifecycle.

Q: WebSockets or polling for location?

A: Drivers often use persistent connection or frequent HTTP for uploads; riders get push (WebSocket/SSE) or poll for driver position on map. Name one and justify battery/network tradeoffs.

Q: Strong consistency for every location update?

A: Latest position is usually eventually consistent per driver with last-write-wins in a cell; matching uses recent enough snapshot. Ride accept needs strong consistency on the ride record.

Q: How is this different from food delivery design?

A: Uber is two-sided real-time match with continuous driver movement; delivery adds merchant prep time and order batching. Both share geospatial indexing but different state machines and SLAs.

Practice interactively

Open the practice session to use the canvas and stages, then review AI feedback.