advanced
2 min answer
Design the mobile architecture for a ride-hailing app used on poor networks, in the background, with continuous location updates.
Show the full answer Hide the answer
The constraints that shape everything
Battery, unreliable connectivity, aggressive operating-system background limits, and a user whose task cannot be abandoned halfway. None of these apply to a web client and all of them dominate here.
Location handling
- Adaptive sampling. High frequency while a trip is active, low frequency otherwise. Continuous high-frequency GPS is the single largest battery consumer in this class of app.
- Batched uploads rather than a request per fix, since radio wake-ups cost far more than the bytes.
- Send current state, not the backlog. After a tunnel or a dead zone, a location from four minutes ago has no dispatch value. Uploading the buffer is an expensive burst carrying nothing useful — discard stale fixes at the client and again on arrival.
- Server-side smoothing, because raw fixes jump and a jittering map reads as a broken app.
State and connectivity
- Local persistence as the source of truth during a trip, so a network gap or an app restart does not lose the trip.
- A queue of pending operations with idempotency keys, retried on reconnection. The client cannot distinguish "not received" from "received, response lost", so the server must deduplicate.
- A push channel for state changes with polling as fallback, since push delivery is best-effort and not guaranteed.
- Explicit connectivity state in the interface. Users tolerate a poor network; they do not tolerate not knowing whether the request went through.
The platform constraints to design around
Background execution is limited and getting more limited. The app cannot assume it keeps running when backgrounded, so anything that must continue needs the platform's specific background location or task mechanism, with a foreground indicator where required.
Push wake-ups are throttled and unreliable on both platforms, and neither ordering nor delivery is guaranteed — so push is a hint to fetch, never a carrier of state.