Stage 1 of 5 · Model
The location stream is the first bottleneck
Start with the data that arrives whether or not anyone requests a ride. There are 60,000 online drivers, and every available driver sends one ping every three seconds. Ride requests average 2,000 a minute and briefly peak at five times that rate.
What you need to know first
For a periodic stream, divide the number of active senders by the reporting interval. Do not size a system only for the user action that looks most important: background location updates can outnumber ride requests by orders of magnitude.
60,000 drivers each send one location ping every 3 seconds. About how many pings per second reach the service?
About 20,000 pings/second.
60,000 ÷ 3 = 20,000 pings a second. Peak ride requests are 2,000 × 5 ÷ 60 ≈ 167 a second. Location updates are about 120 times as frequent, so they need a cheap, short-lived write path separate from durable trip history.
What the stage asks
What would you store for each location ping, and which location data would you persist durably? Explain the freshness and ordering rules.
Reference answer
Keep the latest position, availability, cell, sequence number, and received time in an expiring index. Persist trip transitions and the location samples required for an active trip or audit separately. A delayed ping with a lower sequence must not move a driver backwards. The raw location stream is high-volume and short-lived; the trip lifecycle is comparatively small and durable.
What a strong answer covers
- Keeps only each driver's latest position in the fast matching index rather than appending every ping as durable trip data.
- Expires or rejects locations older than ten seconds.
- Uses a sequence number or timestamp so a delayed older ping cannot overwrite a newer position.
The reasoning
- 20,000 location pings/second versus about 167 peak ride requests/second.
- The live matching index and durable trip history have different retention and write requirements.
- Freshness and event order are correctness rules, not cache-tuning details.
The location path dominates request count, so putting every ping into the same durable relational write path as trips couples cheap refreshes to expensive lifecycle guarantees. Keep a compact current-position index with a short TTL and a monotonic sequence. Durable storage owns the request, offer, acceptance, pickup, completion, and cancellation transitions. If a location is too old or out of order, discard it rather than making a confident match from stale data.
Where another engineer could land differently
Persisting a full location history can be appropriate for safety, billing, or regulation, but stream it to separate partitioned storage with an explicit retention policy; do not make the matcher scan that history.