SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 27
Design live driver tracking and ETA for a ride
Once a driver accepts, the rider watches the car move toward them on a map with "arriving in 4 min". During the trip both see progress toward the destination and an updated arrival time. Phones lose signal in tunnels and parking garages all the time.
Requirements
- The driver app reports its location while heading to pickup and during the trip.
- The rider sees the driver's position on the map, a few seconds behind reality at most.
- Show ETA to pickup, then ETA to destination, updated as traffic and the driver's route change.
- After either phone reconnects, the rider sees the current position quickly rather than a replay of old points.
Constraints and assumptions
- 1 million concurrent active trips at peak.
- Drivers send a GPS fix every 4 seconds during a trip (about 250,000 updates per second); each update is about 100 bytes.
- The rider's map should lag the driver by no more than 5 seconds; the ETA should refresh at least every 30 seconds.
- Mobile connections drop for 10 to 60 seconds at a time; the driver app should not upload more often than once every 4 seconds to save battery and data.
- A routing engine with live traffic exists; one route computation costs about 20 ms of CPU.
Out of scope for the first sketch
Matching drivers to riders · Pricing · Turn-by-turn navigation for the driver · Building the road graph and traffic model
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design live driver tracking and ETA for a ride
Finish your first sketch before answering these. Cross out freely.
- The driver goes through a tunnel for 40 seconds. What does the rider see, and what happens when the phone reconnects with a batch of old points?
- The driver's connection and the rider's connection land on different servers. How does each update reach the right rider?
- Computing a route for every location update is too expensive. When do you recompute the ETA, and what does the rider see in between?
- The rider shares the trip with three friends through a link. What changes in fan-out and access control?
- GPS jitter puts the car on a parallel street or makes it jump backwards. Where do you fix that?
Compare afterwards: worked approaches and reading at sketchbook /questions/ride-tracking-eta/review