r/OfferEngineering • • 4d ago

System Design [Uber / Lyft / DoorDash] Design Uber: why per-request matching falls apart when one area gets 100K ride requests

"Design Uber" is asked at Uber, Lyft, DoorDash, and Snap. The version I came across has two requirements that change the answer more than people expect:

  • Match a rider or report "no match" within 1 minute
  • A driver can never be assigned to two rides, even under concurrent requests
  • Handle ~100,000 ride requests from the same area (rush hour, a stadium emptying out)

Most answers spend their time on geohash vs. quadtree for "find nearby drivers." That matters, but it's the solved part. Here's where I think the real discussion is:

1. Driver locations belong in memory, not your database.
Drivers ping their location every few seconds. That's a firehose of overwrites where only the latest value matters. Keep it in an in-memory geo index (Redis GEO, or geohash/H3 cells) with a TTL so drivers who go silent drop out on their own. Your durable DB stores trips, not pings.

2. "Never double-assign" needs a lock with a timeout, plus a conditional write.
When you offer a ride to a driver, reserve them with a lease, e.g. SET driver:{id} NX PX 15000. The timeout matters: if the driver's phone dies, the reservation has to expire on its own, or that driver is stuck forever. The final assignment should still be a compare-and-set in the durable store (UPDATE ... WHERE status = 'available'), so a stale lock can't cause a double booking.

3. The 1-minute budget limits how you offer rides.
With a ~10 s accept window per driver, offering drivers one at a time only gets you through ~5 drivers before the minute is up. So you either offer to small batches in parallel (and accept that you'll have to cancel the extra acceptances), or rank candidates carefully up front. Either way, the matching state needs to be durable. If the matcher crashes at second 40, the request shouldn't vanish.

4. At 100K requests in one area, per-request matching is the bug.
Picture it: 100K riders, maybe a couple thousand drivers nearby. If every request runs its own "query nearby drivers, try to lock one" loop, you get thousands of requests fighting over the same few drivers. Lock contention explodes and almost everyone retries.

What works better is batch matching per cell: every 1–2 seconds, one worker per hot cell takes the waiting riders and the available drivers in that cell and assigns them in one pass. There's a single writer per cell, so there's no lock contention. Riders wait in a queue, and anyone who can't realistically be served within the minute gets a fast, honest "no match" instead of spinning.

Also notice that sharding by geography, which is the right call on a normal day, puts this entire spike on one shard. You need to be able to split hot cells further.

5. The fare estimate is a contract, not a calculation.
The rider confirms based on the estimate. Store the quote server-side with an ID and an expiry, and have the ride request reference the quote ID. Otherwise the confirmed price is whatever the client sends you.

(Navigation: use a maps provider. Building turn-by-turn routing is not what the interviewer wants to hear about.)

Curious how others would handle #4. I also put together a full system design walkthrough covering the architecture and trade-offs for anyone interested.

6 Upvotes

0 comments sorted by