Lesson 12 of 15
44. Design Ride-Hailing with Surge Pricing (Uber / Rapido)

Score yourself

3 min read+10 XP

Score yourself

Give yourself 0, 1 or 2 points per row.

Area0 points1 point2 points
RequirementsStarted drawingRequest and matchLocation rate, double assignment, price locking and live tracking agreed
EstimatesNoneNumbers, not used laterLocation writes vs ride volume drove in-memory index and city sharding
API and dataSkippedRequest endpoint onlyDriver socket, quote with lock, idempotent trip events, index vs log vs trips
High-level designDB query for nearestIndex, no matching flowQuote, match by ETA, offer, atomic assign and trip states walked
Deep diveHand-wavedOne topicIndex, ETA matching with atomic assignment, smoothed capped surge or state machine done properly
Trade-offsNone namedNamed when askedRaised unprompted (update rate vs battery, greedy vs batch matching, surge smoothing)
CommunicationLong silencesMostly clearThought out loud, checked in, managed time

12 to 14: strong hire signal. 8 to 11: solid, polish the weak rows. Under 8: redo the round in a week, timer on.

The bar: fresher vs SDE-2

FresherSDE-2
LocationsStore in a tableIn-memory cell index per city, stale expiry, history to a stream
MatchingNearest by distanceETA ranking, sequential offers with timeouts, atomic assignment, batch matching
SurgePrice × demandPer-cell ratio, smoothing, caps, locked into quotes
TripsStatus columnState machine with idempotent events and timeouts
ScaleOne clusterSharded by city, stateless matchers, cached ETAs

Common mistakes

  • Writing every location update to the main database.
  • Matching by straight-line distance only.
  • Offering one trip to many drivers at once without atomic assignment, so two accept the same rider, or one driver gets two.
  • Recalculating price during the trip instead of locking the quote.
  • Trusting the phone's view of trip state without idempotent events.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz