← Mobile System Design: The 45-Minute Playbook

Worked example: live order tracking

Lesson 4 of 42 min read

Real-time location, battery, reconnects, and what to do when the socket dies.

"Design the order tracking screen for a food delivery app." This prompt is popular in India for a reason: every constraint is a mobile constraint.

Scope

Order status timeline, rider position on a map, ETA, and it must behave when the app is backgrounded or the network drops. Out of scope: the rider's own app and the dispatch algorithm.

Transport

  • WebSocket while the screen is in the foreground: low latency, one connection.
  • Push for status changes when the app is backgrounded — "order picked up", "arriving". Push wakes the app; the app then pulls the authoritative state.
  • Polling as the degraded fallback, every 15-30 seconds, when the socket cannot be established.

Say explicitly that you do not keep a socket open in the background. That is a battery and OS-limits answer, and it is what separates a mobile answer from a web one.

Location on the map

  • The server sends the rider's position at a sane cadence — every 5-10 seconds, not every GPS fix.
  • Interpolate between updates so the marker glides instead of teleporting. This is a client-side animation, not more data.
  • ETA comes from the server. Computing it on the client from a straight-line distance will be wrong and visibly so.

Reconnects and correctness

  • Reconnect with exponential backoff and jitter, so a server blip does not become a thundering herd.
  • On reconnect, fetch the current state once rather than replaying missed events — simpler and always correct.
  • Every update carries a sequence number or timestamp; drop anything older than what you already show, or the marker will jump backwards.

Battery and lifecycle

Close the socket in onStop, reopen in onStart. Stop map animations when not visible. Never hold a wake lock for a tracking screen — the OS will punish the app and users will notice the drain before they notice the feature.

Failure states, explicitly

No network: show the last known status with a timestamp — "updated 2 minutes ago" — not a spinner. Socket down but push working: the timeline still advances. Everything down: a phone number for the rider. Designing the degraded experience is the part most candidates never reach, and it is where the round is won.