Black Friday 50% off any plan, for life Ends Nov 30

System design

Design Uber

A ride-hailing app looks simple from the back seat: type where you are going, see a price, tap Request, and a car shows up. Behind that tap, millions of drivers report their position every few seconds, and the system has to find the nearest free one from that moving picture, offer the ride to exactly one driver at a time, and move on quickly when a driver says no.

The hard parts are all on the driver side. About two million location updates arrive every second at the peak, a driver must never be handed two rides at once, an offer that nobody answers must not leave a rider waiting forever, and a stadium full of people asking for cars from the same street must not break matching for everyone else. This write-up follows one ride: Jane, at Moscone Center in San Francisco, going to SFO, and John, the driver two streets away who takes her there.

Now draw it yourself, cold

You can nod along to a finished design and still freeze five minutes into the real round. In the 14-day free trial you draw this system yourself while an interviewer asks questions and grades every decision.

14-day free trial. Cancel anytime with one click.

I have an account

Understanding the problem

Functional requirements

  1. Riders can enter a pickup and a destination and see a fare estimate.
  2. Riders can request a ride and are matched to a nearby available driver.
  3. Drivers can accept or decline a ride request, then navigate to the pickup and the destination.
  4. Riders and drivers can see each other's live location until the trip ends.

Questions worth asking, with the answers you will usually get:

  • How many drivers, how often? About 10M online at the peak, each phone sending its position about every 5 seconds.
  • How many rides? About 20M a day, and riders check a price about five times for every ride they actually request.
  • How fast must a match be? The rider should hear within about a minute that a driver accepted, or that none was found.
  • How long does a driver get? One offer at a time, about 15 seconds to accept or decline. No answer counts as a decline.
  • Is the quoted price binding? Yes, for a few minutes. Surge pricing exists; design it at a high level only.
  • Can we lose a location update? Yes, the next one comes 5 seconds later. A ride request can never be lost.
  • Maps? An existing routing service returns road distance and travel time between two points, and the apps draw turn-by-turn directions from it.

Out of scope: shared rides and ride categories, scheduled rides, ratings, payments and driver onboarding.

Non-functional requirements

  1. Correct matching. A driver never has two rides at once and a ride never has two drivers. This is the one place that needs strong consistency.
  2. Fast matching. A rider knows within 1 minute whether a car is coming.
  3. Location writes at scale. 10M drivers every 5 seconds is about 2M writes a second at the peak.
  4. Hot spots. 20,000 requests from a few blocks in 15 minutes after a concert, with none dropped.
  5. Fresh enough positions. A driver's position in the index is at most 5 to 10 seconds old, and live location reaches the other app within about 2 seconds. A lost update is fine.
  6. Quick, honest estimates. A price in under a second, honoured for 5 minutes.

Ranked: correct assignment first, because a double-booked driver leaves one of two riders without a car; then match time; then how fresh a position is. Notice the split. Locations can be lossy and slightly stale, so that data favours availability. Ride assignment cannot, so that data favours consistency. Much of the design follows from keeping those two kinds of data apart.

Back-of-the-envelope estimation

A day is 86,400 seconds, and the peak runs about three times the average.

Location updates. This is the dominant load.

10M drivers / 5 s     = 2M updates / s at the peak
2M x ~100 B           = ~200 MB / s coming in
latest positions      = 10M x ~100 B = ~1 GB

The data is tiny and the write rate is huge. That shape rules out a disk database for the index and points at memory.

Rides and estimates.

rides:      20M / day  ≈ 230 / s,  peak ≈ 700 / s
estimates:  100M / day ≈ 1,160 / s, peak ≈ 3,500 / s

Both are small next to the location updates. One Postgres primary with replicas handles them comfortably.

Trips in progress. A ride lasts about 25 minutes from acceptance to drop-off.

20M x 25 min / 1,440 min ≈ 350,000 trips at once, about 1M at the peak
1M trips x one update / 5 s = 200,000 live positions / s to riders

Connections. Every online driver keeps a connection open for offers, and every rider on a trip keeps one for live location.

10M drivers + 1M riders = ~11M sockets; at ~50K per gateway, about 220 gateways
QuantityEstimateWhat it decides
Location updates2M / s at the peakAn in-memory geo index, sharded by city; adaptive update intervals
Current positionsAbout 1 GBOnly the latest position is indexed; history goes elsewhere
Ride requests700 / s at the peakPostgres for rides, with a queue in front of matching
Estimates3,500 / s at the peakOne routing call and one insert each
Trips in progressAbout 1M at the peakPush over WebSockets, not polling
Open connectionsAbout 11MA fleet of gateways scaled by connection count

Core entities

  • Rider: id, name.
  • Driver: id, vehicle, status (offline, available, offered, on_trip).
  • Fare: id, rider, pickup, destination, price, surge multiplier, expires_at. The quote the rider saw, saved before anything else happens.
  • Ride: id, rider, driver, fare, pickup, destination, status (matching, accepted, arrived, in_progress, completed, cancelled, no_driver), offered_driver, offer_expires_at.
  • Location: driver, lat, lng, heading, updated_at. Only the latest one is used for matching.

Fare is its own entity on purpose. If the request carried the price, a modified app could send a lower one. With a saved fare, the request names a quote the server made.

API

POST /fares { pickup: {lat, lng}, destination: {lat, lng} }
  -> 201 { fare_id, price, eta, expires_at }

POST /rides { fare_id }
  -> 202 { ride_id, status: "matching" }
  409 if the fare has expired: the app asks for a new estimate

GET /rides/{id} -> 200 { status, driver, driver_location }

POST /drivers/location { lat, lng, heading, ts } -> 204

PATCH /rides/{id} { action: accept | decline | arrived | start | complete }
  -> 200 ride
  409 if the offer has expired or gone to another driver

The rider or driver always comes from the auth token, never from the body. POST /rides answers 202 Accepted, not 201, because the ride exists but the work it starts (matching) is still running. The app follows it with GET /rides/{id} or a live connection. In practice the driver app sends its location and receives offers over one long-lived connection rather than separate HTTP calls; the shapes are the same.

High-level design

1. Fare estimates

Jane types SFO. Her app sends POST /fares through the load balancer to the Fare Service, which asks the Routing Service for the drive: 21 km and 25 minutes. Straight-line distance would be wrong in any city with rivers, bridges and one-way streets, so price from the road graph.

($2.50 base + $1.10 x 21 km + $0.35 x 25 min) x surge 1.0 = $34.35
$34.35 + $2.95 booking fee = $37.30

See it in the flythrough02 · Fare estimate

The Fare Service reads the surge multiplier for Jane's pickup cell (1.0 right now; the surge deep dive explains where it comes from), writes a Fare row with expires_at = now + 5 minutes, and returns it. Nothing about the price is decided again later.

See it in the flythrough03 · Keep the quote

2. Requesting and matching a ride

Matching needs to know where drivers are, so start there. John's app sends his position every 5 seconds to the Location Service, which writes it into a geospatial index: a Redis GEO set per city.

GEOADD drivers:{sf} -122.407 37.787 john

Jane taps Request. Her app sends POST /rides { fare_id }. The Ride Service checks the fare is hers and has not expired, inserts a ride with status matching, and answers 202 straight away. The app never waits on an open request for a minute.

See it in the flythrough04 · Request

The Ride Service hands the ride to the Matching Service, which asks the index for drivers near the pickup:

GEOSEARCH drivers:{sf} FROMLONLAT -122.401 37.784 BYRADIUS 3 km ASC COUNT 20

See it in the flythrough05 · Drivers nearby

That returns the 20 nearest by straight line. Nearest in a straight line is not nearest by road: Sarah is 0.4 km away but across a freeway, 7 minutes by car, while John is 0.6 km away and 3 minutes. The matcher keeps the candidates whose status is available (searching again with a larger count or radius if too few are), asks the Routing Service for all their driving times in one batch, and picks the shortest.

See it in the flythrough06 · By drive time

It records the offer on the ride (offered_driver = john, offer_expires_at = now + 15 s) and sends it to John's app over his open connection, with a push notification as a fallback.

3. Accepting or declining

John taps Accept. The Ride Service changes the ride only if the offer is still his and still open:

UPDATE rides
SET driver_id = 'john', status = 'accepted'
WHERE id = 'r_7f3'
  AND status = 'matching'
  AND offered_driver = 'john'
  AND offer_expires_at > now();

One row changed means he has the ride. Zero rows means his tap arrived after the offer expired or moved on, and he gets 409. Without that WHERE, a late accept could overwrite a ride already given to someone else.

See it in the flythrough08 · Accept once

If John taps Decline, or 15 seconds pass with no answer, the matcher offers the ride to the next driver on its list. Once he has accepted, his app gets the route to the pickup from the Routing Service, and he moves the ride along with arrived, start and complete. Each step updates the ride and tells Jane, and at complete John becomes available again.

See it in the flythrough09 · On the way

Here is the whole request path in one view:

See it in the flythrough10 · Every request

4. Seeing each other live

John's app already sends his position every 5 seconds. While he is on a ride, the Location Service also writes it to a small key for that ride:

SET ride:r_7f3:driver {lat, lng, heading, ts} EX 60

The simplest working version: Jane's app polls GET /rides/r_7f3 every 5 seconds, and the Ride Service reads the status from the database and John's position from that key. The app animates the car along the route between updates so it glides rather than jumps. John sees Jane the same way: her app sends her position every 10 seconds until pickup, and his app reads it. When the ride ends, both stop.

Polling works, but it is wasteful at a million trips. The last deep dive replaces it with push.

Deep dives

1. How do you store 2M location updates a second and still find nearby drivers fast?

See it in the flythrough11 · John's pings

BadA row per driver in Postgres

Keep a drivers table with a location column and a PostGIS index, update it on every ping, and run a radius query for each request. Each update in Postgres writes a whole new row version, updates the spatial index, writes both to the WAL and leaves a dead row for vacuum. At 2M updates a second that is far past one database, and sharding it a hundred ways to keep up is a lot of machinery for 1 GB of data that is worthless five seconds later.

See it in the flythrough12 · Bad: a row per ping

GoodBatch the writes into a geospatial store

Buffer pings and write them in batches every few seconds to a store built for geo queries. It is the usual fix for a write-heavy table, and it does cut per-write overhead. But batching cuts transactions, not rows: each 10-second batch still holds about 20M positions, so the store applies 2M index updates a second and needs nearly as many shards as before. It also still pays for disk durability that the data does not need. And each batch makes the index older. With pings every 5 seconds and batches every 10, a driver can be 15 seconds, about 200 m at city speed, from where matching thinks they are, so John gets the offer as the nearest car just after he turned onto the freeway away from Jane.

GreatThe latest position only, in memory, sharded by city

Keep only each driver's current position, in Redis. Redis GEO stores members of a sorted set with a 52-bit geohash as the score, so GEOADD is one O(log N) write, and GEOSEARCH ... BYRADIUS checks the cells covering the circle and returns the nearest in order. An equivalent design uses H3 cells: a driver sits in the set for their resolution-9 cell (about 0.1 km²) and a search reads that cell and rings of neighbours around it. Either way, a driver crossing into a new cell is a cheap move between keys.

See it in the flythrough13 · Great: latest in memory

Sharding follows geography. One key per city (or a few per large metro) puts every search on one shard, and about 40 shards at up to 50,000 writes a second each take the 2M peak, each with a replica. A pickup near the edge of a region searches both regions' keys.

A few details a senior candidate names:

  • Stale drivers. Redis expires whole keys, never members of a sorted set, so a phone that dies mid-shift would stay searchable forever. The Location Service runs one Lua script per ping that also writes ZADD seen:{sf} <now> john. The {sf} hash tag keeps both keys on one shard, so the script can touch both. A sweeper removes anyone silent for 30 seconds from both sets.
  • Adaptive update intervals. Fewer pings means fewer writes. The app reports every 5 seconds when moving or on a trip, every 15 seconds when parked in an airport queue, and skips a move under 20 m, but always sends a heartbeat at least every 15 seconds, well inside the 30-second sweep. That cuts the average rate by a third or more. The server can also ask for more frequent updates near a pickup.
  • Failover. If a shard's primary fails, its replica may be a second behind. Every driver sends a fresh position within 15 seconds (5 if moving), so the next pings refill the index; nothing needs restoring.
  • Why not a quadtree? It suits Yelp's businesses, which almost never move. Moving points mean a removal and reinsert on many updates, plus splits and merges as drivers bunch up at a stadium and spread out again, all under locks. Cells with a fixed grid avoid that work.

History is a separate concern. Pings from drivers on a trip also go to Kafka and on to object storage, for the route record, fare disputes and analytics. Matching never reads them.

2. How do you make sure a driver never gets two rides, and a ride never gets two drivers?

Many rides are matched at once. Two riders a block apart can both find John nearest in the same second, and a ride near a region border searches its neighbour's drivers too, so even with one matcher per region two workflows can reach the same driver.

BadA lock in one matcher's memory

Each matcher keeps a set of drivers it has offered and skips them. It is what anyone writes first, and with one matcher it works. But a lock in one process's memory means nothing to the other matchers. Two riders a block apart on a region border are matched in the same second by two matchers, both find John nearest, and both send him an offer. He accepts one; the other rider loses 15 of her 60 seconds to an offer that can never be taken. Moving the lock to a status flag set to offered with no expiry fixes that and adds a new failure: if the matcher that set it crashes, John stays offered forever. A cron job that resets old offers every 5 minutes frees him minutes late, while riders around him are told no driver was found.

GoodA conditional status update with an expiry

UPDATE drivers SET status = 'offered', offer_expires_at = now() + interval '15 seconds'
WHERE id = 'john'
  AND (status = 'available' OR (status = 'offered' AND offer_expires_at < now()));

Only one matcher wins, and an abandoned offer frees itself when its time passes. This is correct. The cost is that every offer attempt is a round trip to the Postgres primary that holds the rides. At the peak, 700 rides a second with up to four rounds each is about 2,800 offer writes a second, plus the attempts that fail. In a busy area those attempts pile onto the same rows: when ten rides near a stadium all want the same three drivers, attempts on John queue behind each other's row lock and most fail. And during a primary failover, tens of seconds, no offer can be made anywhere.

GreatA lock with a TTL, and the database as the final word

Model each driver as a small state machine: available, offered, on_trip, available again. The offered state is a Redis lock whose TTL is a little longer than the 15-second offer, so it outlives any accept the database would still take:

SET lock:driver:john r_7f3 NX PX 20000

A matcher that fails to take it skips John and tries the next candidate, so he never sees two offers. If he declines, the matcher deletes the lock only if it still holds r_7f3 (a Lua compare-and-delete), so it never frees a lock another ride took after this one expired. If he never answers, it expires by itself.

See it in the flythrough07 · Lock and offer

The ride side lives in Postgres, the source of truth: the conditional accept in the high-level design succeeds once. And because a Redis failover can lose a lock that was not yet copied to the replica, one more guard makes a double booking impossible rather than unlikely:

CREATE UNIQUE INDEX one_active_ride_per_driver ON rides (driver_id)
WHERE status IN ('accepted', 'arrived', 'in_progress');

If two rides ever reach John, the second accept violates the index, gets 409, and that ride goes back to matching. The lock keeps the common case fast; the database keeps it correct.

See it in the flythrough15 · A lost lock

3. What happens when a driver declines, ignores the offer, or the matcher crashes?

The rider has one minute. With 15-second offers that is up to four drivers, so every round has to start on time even if the process that sent the last offer is gone.

BadWait in the matcher's memory

Send the offer, then sleep 15 seconds or set an in-process timer. It is the obvious way to write it: the loop reads top to bottom and needs nothing new. The timer lives only in that process. At the peak, 700 rides a second each spend up to a minute in matching, so about 42,000 rides are waiting on a timer at any moment. If 40 matchers share them, a routine deploy that restarts one matcher drops about 1,000. Each of those rides sits in matching with nobody watching it. John's lock expires, no next driver is offered, and Jane watches "Finding your driver" until she gives up.

See it in the flythrough16 · Bad: wait in memory

GoodA delayed message

When the matcher sends an offer, it also enqueues a message that becomes visible after 15 seconds (SQS with a delay, or a Redis sorted set of due times polled by workers). When it fires, any worker reads the ride. If it is still matching with offered_driver = john and the same attempt number, the worker releases John's lock, adds him to the ride's declined list and starts the next round. If he accepted, the message is ignored. The attempt number makes a duplicate firing harmless. The cost is one ride's logic spread over handlers: the timer, a decline, an accept and the 60-second deadline each arrive as a separate message, and each must check the attempt number. Miss the check in one, and a decline that lands in the same second as the timer starts two rounds, and two drivers get offers for one ride.

GreatA durable workflow per ride

Run each ride's matching as a workflow in a durable execution engine such as Temporal:

loop until 60 s have passed:
  candidates = nearby available drivers, minus those who declined
  lock the best one and send the offer
  wait for accept, decline, or a 15-second timer
  accepted: done
otherwise: status = no_driver where still matching;
  tell the rider only if that changed the ride

The where still matching matters: an accept can land in the database just before the timer fires. If the update changes nothing, the ride was accepted and the rider hears that instead, and the workflow also re-reads the ride before each round. The engine stores the workflow's progress and its timers, so if the worker running it dies, another picks it up at the same line. The logic reads like the plain loop it is, rather than being spread across message handlers.

See it in the flythrough17 · Great: durable timer

Two details matter in either version. Each round searches again, because 30 seconds later the second-best driver may have driven away and a better one may have arrived. And after two rounds with no taker the radius widens from 3 km to 5 km. A team may also choose to offer the ride to two drivers at once after a decline: matching is faster, the conditional accept still picks exactly one, and the cost is a driver who taps Accept and loses.

4. How does surge pricing work?

When riders in an area far outnumber drivers, the price rises. That cuts demand a little and pulls drivers toward the area.

BadCount on every request

Work surge out when it is needed: for each estimate, count the available drivers near the pickup and the open requests nearby, and divide. It needs no new component and is always current. At the peak that is 3,500 counts a second, each a radius search over the geo index plus a count of open rides, and they concentrate on the busy downtown cells, so the extra reads land on the hottest shards at the worst time. The number is also instantaneous. Two drivers accepting rides between Jane's two taps can move the ratio enough to change her price from $37.30 to $44.17 and back within a minute, and riders read that as the app cheating them.

GreatStreaming counts per cell

A stream processor (Flink or Kafka Streams) reads the location stream, counting available drivers per H3 resolution-7 cell (about 5 km²), and the fare and ride events, counting estimates and requests per cell, over a sliding 5-minute window. Once a minute it turns each cell's demand-to-supply ratio into a multiplier, blends in neighbouring cells because drivers cross between them, limits each change to 0.2 a minute so the price does not flap, caps it, and writes surge:{cell} to Redis with a 5-minute TTL.

See it in the flythrough19 · Surge

The Fare Service reads the pickup cell's value at quote time, defaulting to 1.0 when the key is missing, and stores it in the Fare row. The price Jane requests with is the price she saw, for the 5 minutes the quote lasts. The same counts can show drivers a map of where demand is.

5. What happens when a concert ends?

60,000 people leave a concert, 20,000 of them request rides within 15 minutes from a few blocks, and about 1,500 drivers are nearby. That is 13 riders for every car.

BadMatch inside each request, first come first served

Do the matching inside POST /rides: search, lock the nearest driver, wait for the answer, and return the driver in the response. It is one request and one handler, with no queue to run. After the concert, 20,000 requests in 15 minutes is about 22 a second, and each holds its connection for up to a minute, so about 1,300 handlers wait at once, all searching the same few blocks. Each takes the first driver it can lock, so the 1,500 drivers go to whoever tapped first, not to the nearest rider. Most handlers time out, the service answers 503 or 504, and the apps retry, which creates duplicate rides and adds load exactly when the service is already full.

GoodA queue, and more matchers

Write the ride and an outbox row in one Postgres transaction before answering 202, and let a relay publish the request to Kafka, partitioned by region. Nothing is lost, even if a crash comes between the two, and matchers scale out on the partitions. The stadium, though, sits in one region, and a partition has one consumer, so adding matchers does nothing for it. Spreading its requests over more partitions to get more matchers puts several of them on the same blocks, each searching the same 1,500 drivers. Each driver's lock goes to one of them and the rest fail and search again, so with 13 riders for every car most of the work is losing races, and every lost race costs a rider another round of their minute.

GreatOne owner per region, matching in batches

Give each region's partition to one matcher, so nobody contends for its drivers. In a hot area that matcher batches: every 2 seconds it takes all the open requests and all the available drivers in those cells and assigns them together, choosing pairs that keep total pickup time low (a greedy pass by shortest ETA, or a proper assignment algorithm). First come first served gives a rider at the north gate a driver who was better for someone at the south gate; a batch does not.

See it in the flythrough18 · Hot spot

Riders wait in request order. The app shows they are queued, and anyone still unmatched after the minute is told no driver was found. Surge rises in those cells, which draws drivers in and evens out demand. The location side is not the problem here: 1,500 drivers updating every 5 seconds is 300 writes a second on one shard. The busy reads, such as every rider's map of nearby cars, go to that shard's replicas.

6. How does live location reach a million riders?

BadPoll the database

Jane's app calls GET /rides/r_7f3 every 5 seconds and redraws the car. It reuses an endpoint that already exists. Across 1M trips at the peak that is 200,000 reads a second on a Postgres that otherwise takes about 700 ride writes a second, close to 300 times its real workload. The row does not even hold the position, which lives in Redis, so every poll also needs a second lookup. Poll every second to make the car move smoothly and it becomes 1M reads a second, which no single primary and its replicas serve.

GoodPoll a cache

Point the poll at the ride:r_7f3:driver key in Redis instead. Redis serves 200,000 reads a second without strain, so this works, and it is a fair answer for a small city. But it is still 200,000 HTTP requests a second through the load balancer, auth and the API servers, most of which find the same position as last time. And the poll adds up to 5 seconds on top of the 5-second ping interval, so the car on Jane's map can be 10 seconds old, about 140 m at city speed, and it jumps instead of gliding.

GreatPush over a WebSocket, routed by ride

When John accepts, Jane's app opens a WebSocket to a connection gateway, which subscribes to the ride's channel on a sharded Redis pub/sub cluster (SSUBSCRIBE ride:r_7f3). When John's position arrives, the Location Service sees from his cached state that he is on ride r_7f3, writes the latest position to the ride's key, and publishes it:

SPUBLISH ride:r_7f3 {lat, lng, heading, ts}

The gateway holding Jane's socket forwards it, well under a second after John's phone sent it. That is 200,000 publishes a second at the peak, each to one subscriber, which a sharded pub/sub cluster handles easily.

See it in the flythrough14 · Live location

If Jane's connection drops, the app reconnects, reads the ride's key for the latest position, and subscribes again, so she never waits for the next update to see the car. Jane's own position goes to John the same way on his channel. State changes (arrived, completed) also go out as push notifications through APNs and FCM in case the app is in the background. When the ride completes, the gateway unsubscribes.

Final design

One request. Jane asks for a price. The Fare Service gets 21 km and 25 minutes from the Routing Service, reads surge 1.0 for her cell, saves a $37.30 fare for 5 minutes and returns it. She taps Request; the Ride Service checks the fare, saves a ride in matching with an outbox row in the same transaction and answers 202, and the relay queues the request for her region. The region's matcher runs a workflow for the ride: GEOSEARCH returns 20 drivers within 3 km, the Routing Service ranks the available ones by driving time, John is locked and gets a 15-second offer. He accepts; the conditional update gives him the ride, and Jane sees him on the way about 10 seconds after she tapped Request.

One ping. John's app sends his position. One Lua script moves him in drivers:{sf} and stamps seen:{sf}. Because he is on a ride, the Location Service also writes ride:r_7f3:driver and publishes the position on the ride's channel, and Jane's car icon moves. The same ping feeds the surge counts for his cell and, on a trip, the route record in object storage.

See it in the flythrough20 · End to end

ComponentRoleScales by
Load balancerRoutes rider requests to stateless servicesInstances
GatewaysWebSockets for driver offers and pings, rider live locationAbout 50K connections each
Fare ServiceRouting call, surge read, saved quoteStateless instances
Routing ServiceRoad distance and driving time, in batchesIts own fleet
Ride ServiceRides, conditional accept, state changesStateless instances
KafkaRide requests by region, location streamPartitions
Matching ServiceOne owner per region, workflow per ride, batches in hot spotsRegions
Workflow engineDurable 15-second timers and the 1-minute limitWorkers
Location ServiceLatest position, sweeper, publishes tripsStateless instances
Geo indexRedis GEO per city, with last-seen setsAbout 40 shards + replicas
Driver locksOne offer per driver, TTL 20 sRedis
Rides DBFares and rides, unique active ride per driver, outboxOne Postgres primary + replicas
Pub/subOne channel per rideSharded Redis pub/sub
Surge job and cacheSupply and demand per cell, one multiplier a minuteStream partitions, Redis

What is expected at each level

Junior. You name the rider, the driver, the fare and the ride, write endpoints to get an estimate, request a ride, send a driver's location and accept an offer, and draw a ride service, a location service and a database. You know that finding nearby drivers needs a location index rather than a scan of every driver, even if which index and how it copes with constant updates needs prompting.

Mid-level. You build the working design: a saved fare so the request cannot change the price, locations in an in-memory geo index (Redis GEO, geohash or H3 cells), a matcher that takes the nearest available drivers, ranks them by driving time and offers the ride to one at a time with a timeout, and an accept checked against the ride's state so it happens once. You own one deep dive end to end, such as locking drivers during an offer or the location write load.

Senior and above. You lead with the numbers (2M location updates a second, about 1 GB of current positions, 700 requests a second, 1M trips in progress) and use them: an index sharded by city and kept in memory because only the latest position matters, adaptive update intervals, a lock with a TTL a little longer than the offer window and the database as the final word, a durable timer per offer, matching owned per region and batched in a hot spot, surge from streaming counts per cell, and live location pushed through pub/sub per ride. At the top of this level you also say what a team would argue about: one offer at a time against several at once, how big a cell or region should be, how stale a position matching can tolerate, and what happens to rides in progress when a region's shard fails.

Common mistakes

  • A database write per ping. 2M updates a second for 1 GB of short-lived data. Keep the latest position in memory.
  • Storing location history in the index. Matching needs where drivers are now, not where they were.
  • The price in the request. Save the quote and send its id.
  • Matching inside POST /rides. The app waits a minute and a surge of requests turns into 503s. Answer 202 and match from a queue.
  • Nearest by straight line. A driver across a freeway is not 0.4 km away. Rank by driving time.
  • A Redis lock as the only guard. A failover can lose it. Make the accept conditional and keep one active ride per driver in a unique index.
  • A lock with no expiry, or a timer in memory. A crash strands a driver or a ride. Give the lock a TTL that covers the offer and keep timers durable.
  • More matchers for a hot spot. They fight over the same drivers. Own each region in one place and batch.
  • Every rider polling every few seconds. 200,000 requests a second to learn nothing new. Push.

Be ready for whichever one they pick

Practice each with an interviewer who grades every step, in the 14-day free trial

Walk into the system design round ready

Practice all 50 system design problems on a whiteboard, with graded feedback on every step, alongside 1,500+ real interview questions. A learning engine brings every problem back before you forget it. 50,000+ engineers have prepared with Firecode.

14-day free trial. Cancel anytime with one click.

Built by former engineers at

I have an account
50,000+engineers preparing with Firecode
1500+real interview questions from top tech companies
14languages, from Python to Rust
FAANG+offers landed at Google, Meta, Netflix, and more
Google Meta Amazon Apple Microsoft Netflix OpenAI Anthropic Stripe Nvidia Airbnb Uber Coinbase DoorDash Spotify Shopify Snowflake Cloudflare Bloomberg Dropbox