Design a ride-hailing service like Uber
HardConceptMedia & Commerce
Answer
Requirements: riders request trips, nearby available drivers are matched within seconds, both sides see live locations, and trips are priced and paid for.
- Location updates: drivers send their position every few seconds; the latest positions are kept in memory (for example, in Redis) rather than written to a relational database each time.
- Geospatial index: geohashes, a quadtree or a hexagonal grid such as H3 let the matching service find drivers in nearby cells quickly.
- Trip service: manages a state machine (requested, accepted, in progress, completed) in a durable database, alongside pricing, surge and payment services.
- Trade-off: more frequent location updates improve matching and ETAs but multiply write load; matching must also claim a driver atomically so that two riders are never assigned the same driver.
More in Media & Commerce
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Design a video streaming service like YouTube | Concept | Hard | Read the answer to Design a video streaming service like YouTube | |||
| 2 | Design a ride-hailing service like Uber | Concept | Hard | Read the answer to Design a ride-hailing service like Uber | |||
| 3 | Design an e-commerce checkout system | Concept | Hard | Read the answer to Design an e-commerce checkout system | |||
| 4 | Design a distributed file storage service like Dropbox or Google Drive | Concept | Hard | Read the answer to Design a distributed file storage service like Dropbox or Google Drive |