SD-27 · Back to the write-up
Design a ETA and Location Sharing
Every ping updates the driver’s latest position and, during a trip, is pushed to the trip’s watchers through its channel; ETAs come from a precomputed road graph fed by live speeds.
Follow a request
A ping reaches the rider
Open the live map
Refresh a trip ETA
Dispatch asks for ETAs
A connection server restarts
Apps
Edge
Services and data
Pipelines and callers
Driver appPings every 4 s
Rider appLive map
Location ingestChecks every ping
Connection serversWebSockets
Location storeLatest per driver
Trip channelsOne per trip
Trip serviceTrips and shares
Location logEvery ping
ETA servicePrecomputed routes
Traffic processorSpeeds per road
DispatchPicks a driver
The numbers, at a glance
on a trip ≈ 200,000/sfree ≈ 200,000/s
400,000Pings in
480,000Polls
240,000Pushes
48,000 work/s160,000 questions/s
A ping, in order
The write to the store and the publish happen together; the log is off the live path.
Driver app
Location ingest
Location store
Trip channel
Connection server
Rider app
1 position, seq 8812
2 SET if newer
3 ok, on trip a91
4 PUBLISH trip:a91
5 point 8812
6 push over socket
7 ack
RequestResponseAsync, does not block
Getting the car onto the map
The first of the two decisions this question is about; the other is precomputed routing.
GET location
mostly unchanged
car 3 s behind
+ Plain HTTP.− 480,000 req/s; 3 s late.
on-trip point
all servers
filter, mostly discard
+ No routing.− Each server reads every point.
PUBLISH trip:a91
subscribed servers
push to rider
+ 1 s; only needed servers.− Long-lived sockets to run.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Apps
App server
SQL databaseETA search
Apps
Ingest × N
Location storeETA, precomputed
Apps
Ingest × NConnection servers
Location storeTrip channelsTrip service
Log + trafficETA
Apps
Ingest × NConnection servers
Location storeTrip channelsTrip service
Log + trafficETADispatch matrix
Was this walkthrough useful?Your vote tells us what to improve next.