The whole course ▾

System Design · Mock interview 6 of 20

Design Uber

Updated 22 Oct 2026 · By Akshay, software engineer, India · 9 min read

Design a ride-hailing app like Uber.

Try it first

Before you read the interview, answer the question yourself. Give yourself 10 minutes: say your design out loud, or sketch it on paper. What would you ask? Which numbers matter? Which boxes, and what's the hard part? Then read on, and score yourself with the feedback at the end.

The video for this mock interview is coming soon.

New System Design videos go up at 6 pm. Subscribe on YouTube so you don't miss it.

Got a doubt? Ask in the comments under the video.Subscribe

Requirements

Requirements
Clarifying questions
->
Core trip flow only? -> Yes
->
Scale? -> 1M drivers online at peak
->
Payments? -> Name it, don't design it
->
Matching speed? -> Under 10 seconds
Functional requirements
Request a trip, see a fare estimate
Match to a nearby driver
Both see each other live on a map
Trip ends, and the fare is charged
Non-functional requirements
->
1M drivers, a location every 4 s
->
Match within 10 seconds
->
One driver, one trip, always
->
Live positions a few seconds old
Out of scope
Payment details
Driver sign-up and ratings
Shared rides
interviewer
Hi, welcome back. Shall we start?
candidate
Yes. This one should be fun.
interviewer
Design a ride-hailing app, like Uber.
candidate
Okay. The real Uber is hundreds of services, so I'd like to narrow it down before drawing anything. Can I ask a few questions?
interviewer
Go ahead.
candidate
Should I focus on the core trip flow: request, match, ride, done?
interviewer
Yes.
candidate
What scale?
interviewer
About a million drivers online at peak, and twenty million trips a day.
candidate
Payments?
interviewer
Mention it, but don't design it.
candidate
And how fast must matching be?
interviewer
Under ten seconds, from tapping Request to a driver accepting.
candidate
Okay. That matching speed will shape a lot.
candidate
So, what it does. A rider can request a trip, and see a fare estimate first. The system finds and matches a nearby driver. Once matched, the rider and driver see each other moving on a map, live. And when the trip ends, the fare is charged, through a payment system I'll treat as a black box.
candidate
And how well. A million drivers, each sending a location every four seconds. A match within ten seconds. One driver gets one trip at a time, always. And positions on the map are at most a few seconds old.
interviewer
Which of those worries you most?
candidate
The mix. One is huge write volume, and another is strict correctness. Holding both in one design is the challenge.
candidate
I'll leave out payment details, driver sign-up and ratings, and shared rides, which make matching much harder. Does that match what you had in mind?
interviewer
Yes. Start with how you'd even know where the drivers are.

Estimation

Estimation
Back of the envelope
1M drivers ÷ 4 s = 250,000 updates/s
20M trips ÷ 100,000 s = 200 trips/s
Peak ~ 600 trip requests/s
Latest positions: 1M × ~100 B ~ 100 MB
WHAT THE NUMBERS DECIDE
250,000positionwrites/s:
inmemory,notadatabase.
600matches/s:modest,
butcontentionmatters.
candidate
Let me look at the numbers first. I think they split the design in two.
interviewer
What load are we dealing with?
candidate
I'll do the location numbers and the trip numbers separately, because they're very different.
candidate
A million drivers sending a position every four seconds is two hundred and fifty thousand updates a second. Twenty million trips a day is about two hundred a second, with a peak around six hundred. And if I keep only each driver's latest position, at about a hundred bytes each, the whole fleet fits in about a hundred megabytes of memory. Location updates outnumber trip requests about four hundred to one.
interviewer
Are trips spread evenly through the day?
candidate
No. Friday nights and rainy evenings are much busier, which is why I plan for the peak.
candidate
So, two hundred and fifty thousand position writes a second, each replacing the last, belongs in memory, not in a database on disk. Six hundred matches a second is modest, but each one has to be correct. So I want a fast, forgetful system for locations, and a careful, consistent one for trips.
interviewer
I like that split.

API and data

API and data
Trips
id, rider, driver,
state, fare
Drivers
id, status, car
Live locations
driver ->
position, cell
assigned
to
now at
Endpoints
1
POST /trips -> trip + fare
estimate
2
Driver socket: location every 4 s
3
Driver: accept or decline an offer
4
GET /trips/{id} + live updates
candidate
Next, the API. There are two kinds of client, so two kinds of API.
interviewer
What does the API look like?
candidate
Riders mostly make requests. Drivers keep a connection open.
candidate
POST slash trips, with pickup and drop-off, returns a trip ID and a fare estimate. Each driver app keeps a WebSocket open, sends its location every four seconds down that socket, and receives trip offers on it. The driver can accept or decline an offer. And the rider gets the trip's state, and the driver's position, as live updates.
interviewer
Why a socket for drivers?
candidate
Offers have to reach them instantly, and they're sending all the time anyway.
candidate
Three kinds of data. Trips: the rider, the driver, the state and the fare, durable, in a database. Drivers: free, busy or offline, and their car. And live locations: each driver's latest position and its map cell, in memory only.
interviewer
In memory? What if you lose them?
candidate
A fresh one arrives in four seconds, so losing it costs nothing. Losing a trip would be a disaster, so trips live in Postgres, sharded by city.

High-level design

High-level design
Driver
app
Location
service
Geo
index
H3
cells,
in
memory
GPS every
4 s
update cell
Rider
app
Trip
service
Trips
DB
Matching
service
request
trip
1
state:
requested
2
find a
driver
3
drivers
near pickup
4
offer
5
Pub/sub
a
channel
per
trip
trip 77
position
live
Trip states
1
Requested
2
Driver assigned
3
Arrived, then on trip
4
Completed, or cancelled
TWO RISKS
250,000updatesa
secondonthelocation
side.Andtworiders
gettingthesamedriver.
candidate
Let me draw the main design.
interviewer
Walk me through what happens when a rider requests a trip.
candidate
First, where the driver positions come from, because matching depends on them.
candidate
Every driver app sends its GPS position to the location service every four seconds. The service works out which H3 cell the driver is in, a hexagon on a grid over the map, and updates the geo index: for each cell, the free drivers inside it. It's all in memory and rewritten constantly, which is fine, because only the latest position matters.
interviewer
Why hexagons?
candidate
Every neighbour of a hexagon is the same distance away, so searching in rings around a point grows evenly in every direction.
candidate
Now the request. The rider app asks the trip service for a trip. It saves the trip in the trips DB, in state requested, then asks the matching service for a driver. Matching asks the geo index for free drivers near the pickup, picks the best one, and sends an offer down that driver's socket. When the driver accepts, the trip moves to driver assigned.
candidate
Once matched, the rider watches the car approach. The location service publishes the assigned driver's positions on that trip's channel in pub/sub, and the rider's connection, subscribed to that channel, pushes each one to the rider app.
interviewer
Why not have the rider poll?
candidate
Every four seconds, from millions of riders, it would be mostly wasted calls.
candidate
A trip moves through a state machine, only forwards. Requested. Driver assigned. Arrived at the pickup, then on trip. And completed, which triggers the payment, or cancelled. Every change is saved, and published to Kafka, so pricing, analytics and notifications can react.
interviewer
Who can cancel?
candidate
Either side, until the trip starts. A cancel is just another state change, with its own rules for fees.
interviewer
What could go wrong here?
candidate
Two things. The location side has to take two hundred and fifty thousand updates a second. And two riders requesting at the same moment could both be given the same nearby driver.
interviewer
Good. Let's take those in order.

Deep dive: a million moving drivers

Deep dive: a million moving drivers
A database row per driver
250,000 disk writes a second
Indexes rewritten constantly
Old positions are worthless
An in-memory geo index
Latest position only, in memory
Split by city across servers
Refilled within seconds if lost
THE CHOICE
Keeponlythelatest
position,inmemory,split
bycity;streamrawGPS
toKafkaforhistory.
High-level design
Driver
app
Location
service
Geo
index
H3
cells,
in
memory
GPS every
4 s
update cell
Rider
app
Trip
service
Trips
DB
Matching
service
request
trip
1
state:
requested
2
find a
driver
3
drivers
near pickup
4
offer
5
Pub/sub
a
channel
per
trip
trip 77
position
live
Location
stream
Kafka,
for
history
raw GPS
split by city
Trip states
1
Requested
2
Driver assigned
3
Arrived, then on trip
4
Completed, or cancelled
TWO RISKS
250,000updatesa
secondonthelocation
side.Andtworiders
gettingthesamedriver.
interviewer
The firehose first.
interviewer
How do you handle two hundred and fifty thousand location updates a second?
candidate
I see two options.
candidate
Option one: a database row per driver. That's two hundred and fifty thousand disk writes a second, constantly rewriting indexes, to keep positions that are worthless four seconds later. Option two: an in-memory geo index that keeps only each driver's latest position, split across servers by city. If a server dies, nothing important is lost: every driver sends a fresh position within four seconds.
candidate
I'd go with the in-memory index, split by city. A trip in Mumbai never needs a driver in Delhi, so cities are a natural shard key, and a big city gets several servers, split by cell.
interviewer
And history?
candidate
For anything that needs history, like ETA models, disputes or fraud checks, I'd stream the raw GPS points to Kafka and store them in bulk, away from the hot path.
candidate
So the location service updates the geo index, split by city, and also publishes every raw point to a location stream in Kafka. The index answers where everyone is right now, in a millisecond. The stream remembers where everyone has been.
interviewer
How long do you keep that history?
candidate
As long as disputes and the models need it. Raw points are cheap in bulk storage.
interviewer
A location server holding a big city dies. What's lost?
candidate
Only the latest positions of drivers in that city, and only for a few seconds. Their apps reconnect to another server and send fresh positions within four seconds, so the index rebuilds itself. Matching in that city pauses briefly, which is acceptable.
interviewer
A driver enters a tunnel and stops sending. Could matching pick them from a stale spot?
candidate
I'd store a timestamp with every position, and treat anything older than about fifteen seconds as unknown, so that driver is skipped until a fresh point arrives. And if a driver stays silent for a minute, I'd mark them offline.
interviewer
Good.

Deep dive: one driver, one trip

Deep dive: one driver, one trip
Matching
1
Free drivers in rings of cells
2
Rank by ETA, not straight-line distance
3
Offer to the best: 15 s to accept
4
No answer? Offer to the next
ONE DRIVER, ONE TRIP
Assignwithaconditional
write:driverfree->busy,
onlyifstillfree.
interviewer
Now, the correctness half.
interviewer
How exactly do you choose a driver, and how do you make sure a driver never ends up with two trips?
candidate
Choosing first.
candidate
I'd look for free drivers in the pickup's cell, then in rings of cells around it, until there are enough candidates. Rank them by estimated time to the pickup, not straight-line distance, because a driver across a river can be close on the map and fifteen minutes away by road. Offer the trip to the best driver, with fifteen seconds to accept. No answer, or a decline? Offer it to the next.
interviewer
Does that fit in ten seconds?
candidate
Usually. The search takes milliseconds. The driver's answer is most of the time.
candidate
And the guarantee. When a driver accepts, I assign them with a conditional write: set this driver busy, on this trip, only if the driver is still free. If two trips race for the same driver, exactly one write succeeds, and the other trip moves on to its next candidate. No locks held while drivers think. And the trip moves from requested to assigned with its own conditional write, so a trip can't get two drivers either.
interviewer
Why not offer each trip to five drivers at once? It would be faster.
candidate
It would, but four drivers would accept and then hear: sorry, taken. Drivers hate that, and start ignoring offers. The conditional write keeps it correct either way, so it's a product trade-off, not a correctness one. Some systems match whole batches of riders and drivers every few seconds instead, for better pairings overall.

Wrap-up

Wrap-up
Next steps
1
Surge pricing per cell, every minute
2
Better ETAs: roads plus live traffic
3
Cities mostly independent: regions
4
Watch match time and acceptance rate
INTERVIEWER'S FEEDBACK
Strong:afastlocationsideanda
carefultripside,offersrankedby
ETA,aconditionalwrite.Nexttime:
whatifnobodyaccepts?Verdict:hire.
interviewer
We're nearly out of time.
interviewer
What would you improve with more time?
candidate
A few things.
candidate
First, surge pricing: when requests outnumber free drivers in a cell, prices rise to balance them, worked out per cell every minute from the trip and location streams. Second, better ETAs from a road graph with live traffic. Third, run cities mostly independently, in nearby regions, so one city's outage stays local. And fourth, I'd watch the time to match, the acceptance rate, and how old the positions are.
interviewer
Which would you do first?
candidate
The watching. Time to match is the number riders actually feel.
interviewer
Okay, let's stop there. Good session. You split the problem early: a fast, forgetful location side, and a careful trip side. Your matching ranks by arrival time, not distance, and the conditional write makes one driver per trip a guarantee rather than a hope. One thing to add next time: what the rider sees while we search, and what happens if nobody accepts. I'd say a hire.
candidate
Thanks. I'll think about the empty search.
Interviewer's feedback

Strong: a fast location side and a careful trip side, offers ranked by ETA, a conditional write. Next time: what if nobody accepts? Verdict: hire.

Score yourself

Interviewers score these seven things. Give your own attempt a tick for each one you did.

  • Asks before drawing. Agrees what the system does, and how well: scale, speed, consistency.
  • Turns users into requests a second and bytes a day, and says what the numbers decide.
  • A small, clear contract, and a data model that fits how the data is read.
  • A working path end to end before any detail. Every box has a reason.
  • Picks the hard parts, compares two options, and chooses one with a trade-off said out loud.
  • What breaks, what happens then, and how users notice. Retries, duplicates, limits.
  • Thinks out loud, checks in with the interviewer, and takes a hint without losing the thread.

0 of 7

Your progress stays on this device.
New System Design videos at 6 pm

Lessons on weekdays, the week's revision on Saturday, a mock interview on Sunday.