44. Design Ride-Hailing with Surge Pricing (Uber / Rapido)
1
The interview prompt2
44.1 What do you ask first?3
44.2 How big is this, really?4
44.3 What are the doors?5
44.4 What do we store?6
44.5 What does the whole system look like?7
44.6 How are location updates handled?8
44.7 How does matching work?9
44.8 How does surge pricing work?10
44.9 How does the trip state machine work?11
44.10 What would you say in the last five minutes?12
Score yourself13
Variations to practise14
Sources15
Code lab44. Design Ride-Hailing with Surge Pricing (Uber / Rapido)
Variations to practise
3 min read+10 XP
Chapters used
Approach (1), Estimation (2), Transactions and atomic assignment (17), Geospatial indexing (18), Real-time connections (21), Message queues and streams (22), APIs and idempotency (24), Failures (29), Checkout and payments (42).
Try these variations
Each is a common follow-up. Answer in two minutes, then check the sketch.
- "Shared rides." → Match riders whose routes overlap; insert pickups into an existing trip if the detour stays under a limit; split the fare.
- "Airport queue." → Drivers at the airport join a FIFO queue in a geofenced zone; trips there are offered by queue order, not distance.
- "Food delivery instead of rides." → Same index and matching, plus restaurant prep time: dispatch the rider so they arrive when the food is ready.
- "10× drivers." → More index shards per city (by cell range), lower update rates for idle drivers, and batch ETA computation.