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)
44.10 What would you say in the last five minutes?
3 min read+10 XP
Step 6: Wrap-up (5 minutes)
- Bottlenecks: location ingestion (in-memory index per city, stream for history), road-ETA calls (cache popular ETAs, compute only for top candidates).
- Single points of failure: none central: the index is rebuilt within seconds from incoming updates; matchers are stateless; trips DB has replicas per city.
- Correctness: atomic assignment, idempotent trip events, quotes that lock prices.
- Safety and trust: share-trip links, SOS, anomaly detection on routes (long detours), and fraud checks (fake GPS).
- Next with more time: shared rides (matching several riders on one route), scheduled rides, driver earnings and incentives, and batch matching across a city.
Memory code: "Fresh positions, honest prices, one driver per trip, every state on record."