Skip to content

System design walkthrough · 12 min

Live order tracking

The rider's dot moving on every customer's map at dinner time. Start with a database row and polling, watch it break, and end with a push design that holds.

Seen in food delivery, grocery, parcel and ride-hailing apps.

The ask

What we are building

Customers want to watch their order come to them: the rider's position on a map, updated every few seconds, plus each status change (accepted, picked up, arriving). Design it for a national app at dinner time, without hurting checkout.

  • A customer sees the rider move within a few seconds of the rider moving.
  • Status changes (accepted, picked up, delivered) are never lost, even if the app was closed.
  • Opening the screen shows the current position at once.
  • Tracking must never slow down ordering or payments.
  • Works on weak mobile networks, and goes easy on battery and data.
Orders a day
5 million
Share between 7 and 10 pm
60%
Order live for
~35 min
Rider sends position
every 4 s

Back of the envelope

How big is it?

Illustrative numbers for this exercise, rounded.

WhatWorkingResult
Orders arriving at peak5M × 60% ÷ 3 h (10,800 s)~280 a second
Orders live at once280/s × 35 min (2,100 s)~580,000
Riders on the roadabout 20 of the 35 minutes are the ride~330,000
Positions coming in330,000 ÷ 4 s~83,000 a second
Polls if screens ask every 2 s~400,000 open screens ÷ 2 s~200,000 a second
Pushes if only changes are sentat most one per position, per watched order≤ 83,000 a second

Build it, then break it

Your turn: design it first

Before reading on, make the three calls yourself. The simulator builds your design and runs it at lunch, dinner and in the rain, with the same riders and customers as the versions below.

1Where does each rider's latest position live?
2How do new positions reach the customer's phone?

Answer every question to run it.

Version 1

Save the position on the order, and poll it

Breaks · at the dinner peak, and takes checkout with it

The simplest design that works: the rider app sends PUT /orders/{id}/position every 4 seconds, which updates two columns on the order's row, and the customer app calls GET /orders/{id} every 2 seconds. One database, one API, nothing new to run.

At dinner that database gets ~83,000 row updates and ~200,000 reads a second on top of its real job. Each update rewrites the row and its index entries, so the database also spends effort cleaning up old versions. Payments and new orders queue behind position updates nobody will look at in a minute.

Row updates
83,000/s
Reads
200,000/s

Try each load. Numbers are illustrative: a small simulation, not a measurement.

Why not…

  • A bigger database?

    Buys one season. The load grows with every order and every open screen, and the database is still where payments live: one busy table slows everything else.

  • Read replicas for the polls?

    Moves the reads but not the 83,000 writes a second, which every replica must also replay. Replicas also lag, so customers see positions from seconds ago.

Go deeper:Polling, long polling, SSE, WebSockets

Version 2

Keep the latest position in memory

Breaks · gets through dinner, then the API fleet falls over in the rain

Split what is hot from what is durable. A rider's position is only useful for seconds, so keep just the latest one per order in an in-memory store (a key per order, expiring after a minute). The order database keeps what must never be lost: status changes, about six per order.

The database is calm again, and a normal dinner gets through. But every open screen still asks every two seconds: ~200,000 full requests a second through the API fleet, each paying for authentication and routing, and half find nothing new because riders only report every four. There is no headroom: when rain sends everyone to their phones, the API fleet tips over. Meanwhile phones wake their radio constantly, and the dot jumps instead of moving.

Database load
status only
Requests to the API
200,000/s
Polls with nothing new
~50%

Try each load. Numbers are illustrative: a small simulation, not a measurement.

Why not…

  • Poll every 10 seconds instead?

    Cuts the load fivefold, and the product with it: the dot freezes, then jumps 100 metres. Live tracking stops feeling live.

  • Cache the answers at the CDN?

    Each answer is private to one order and changes every few seconds, so there is nothing for a cache to share between users.

Go deeper:Hot keys in Redis

Version 3

Push each change down an open connection

Holds · at 30× lunch, with room to spare

While the tracking screen is visible the app keeps one open connection (WebSocket, Server-Sent Events or MQTT) to a gateway. Riders' positions go to an ingest service and onto a stream partitioned by order id, so each order's updates stay in order. A fan-out service finds which gateway holds the watcher's connection and hands it a small message to push.

Opening the screen first fetches a snapshot (latest position and status), then applies pushed changes. Status changes are written to the order database first and pushed second, so a phone that was offline can always catch up. The app animates the dot between points, so it glides instead of jumping.

The load now follows how often riders move, at most one message per position for each watched order, and an open connection costs a few kilobytes of gateway memory instead of a full request every two seconds.

Messages
≤ 83,000/s
Full requests
only on open
Open connections
~400,000

Try each load. Numbers are illustrative: a small simulation, not a measurement.

Why not…

  • Push straight from the ingest service?

    Then every ingest machine must know where every customer is connected. The stream and fan-out separate taking positions from delivering them, so each side scales and fails on its own.

  • Mobile push notifications for positions?

    Built for occasional alerts, not a message every few seconds: delivery is best-effort and can be delayed. Fine for 'your order is arriving', wrong for a moving dot.

  • WebSocket, SSE or MQTT?

    Any of them works. SSE is simplest when only the server talks, WebSocket when the app sends too, and MQTT is built for flaky mobile links. Real companies have shipped each (below).

Go deeper:Message fan-outPartitions and consumer groups

Harden it

Deploys, dead zones and hot cities

Holds · through deploys, dead zones and hot cities

Deploys: restarting a gateway drops its connections all at once. If every phone reconnects at the same instant, the new gateways fall over. Reconnect after a random, growing delay, and drain old gateways slowly.

Gaps: number every message per connection. A phone that reconnects sends the last number it saw, and gets what it missed (or simply a fresh snapshot). Old positions are worthless, so give them a lifetime of seconds and keep only the newest; status changes live longer and must arrive.

Fallback: if the connection cannot be made, the app polls slowly, with a randomised and growing delay, so a push outage never turns into a polling flood.

Hot spots: partition the stream by order id, not by city, or one city's dinner rush lands on one partition. Store each rider's trail (for disputes and delivery-time models) in batches in cheap, time-partitioned storage, never as row updates.

Go deeper:Reconnect storms after a deployChat reconnect storm (animated use case)Hot partition key

Putting it together

The final design

Positions take a fast path that may drop old updates and keeps only the latest. Status changes take a durable path: written to the database first, pushed second, never lost. Polling remains only as a slow fallback.

  1. Rider app

    Sends its position every few seconds, and status changes as they happen.

    Watch out: Dead zones: positions arrive late and in bursts; keep the newest, drop the rest.

  2. Ingest service

    Accepts positions, checks them, and puts them on the stream.

    Watch out: Spikes when many riders come back online at once; it must shed load rather than queue for minutes.

  3. Stream (by order id)

    Keeps each order's updates in order and decouples taking positions from delivering them.

    Watch out: Partitioning by city makes one partition hot at dinner.

  4. Position store

    Latest position per order, in memory with a short expiry, for snapshots.

    Watch out: Treat it as a cache: losing it only costs a few seconds of positions.

  5. Order database

    The durable truth for status changes.

    Watch out: Must never take position traffic again.

  6. Fan-out service

    Finds the gateway holding each watcher's connection and hands it the message.

    Watch out: A stale map of who is connected where: refresh it from gateway heartbeats.

  7. Connection gateways

    Hold the open connections and push small messages down them.

    Watch out: Deploys and crashes cause reconnect storms; spread reconnects and drain slowly.

  8. Customer app

    Snapshot on open, then apply pushes; animate between points; fall back to slow polling.

    Watch out: Out-of-order messages: ignore anything older than what is on screen.

From boxes to an API

API and data model

Each box in the final design becomes an endpoint or a table. Positions and status changes take separate paths: positions are frequent, small and disposable; status changes are rare and must never be lost.

Endpoints

  • POST/v1/riders/me/positionsCalled by Rider appA small batch of recent positions every few seconds; accepted at once and put on the stream, never written to the order database.
  • POST/v1/orders/{id}/statusCalled by Rider appPicked up, arriving, delivered. Carries an event id, so a retry after a dropped connection is recorded once.
  • GET/v1/orders/{id}/trackingCalled by Customer appA snapshot when the screen opens: current status and the latest position from the position store.
  • WS/v1/orders/{id}/liveCalled by Customer appOne open connection while the screen is visible; the gateway pushes each new position and status. Falls back to slow polling of the snapshot.

Data

  • orders

    Key: order_id

    order_id, customer_id, restaurant_id, rider_id, status, status_updated_at

    The durable truth. Updated about six times per order (status changes), never with positions.

  • order_events

    Key: (order_id, event_id)

    order_id, event_id, type, occurred_at, recorded_at

    Every status change, once. The event id from the rider app makes retries harmless.

  • position store

    Key: pos:{order_id}

    lat, lng, heading, recorded_at; expires after 60 s

    Latest position only, in memory. Losing it costs a few seconds of map, so it is not worth a durable write.

  • positions stream

    Key: partition by order_id

    order_id, lat, lng, recorded_at

    Keeps each order's positions in sequence and spreads orders evenly; splitting by city would put a rainy city on one partition.

From their own write-ups

How real companies did it

  • Uber found that at one point 80% of requests to its API gateway were polling calls, draining batteries and congesting networks. It built a push platform (RAMEN) on Server-Sent Events with a heartbeat every 4 seconds, sequence numbers so a reconnecting app resumes where it left off, and a lifetime on each message. It later served over 1.5 million concurrent connections.

    Uber Engineering: Uber's Real-Time Push Platform (2020) ↗
  • Wolt moved order tracking from polling to WebSockets, relaying updates through a per-user channel in Redis Pub/Sub. On connect the app polls once more to close the gap between its snapshot and the first pushed update, and if the connection drops it falls back to polling only after a randomised, exponentially growing delay.

    Wolt: From Polling to WebSockets: Improving Order Tracking User Experience (2023) ↗
  • Zomato describes polling as making live tracking feel stale, with rider markers that jumped rather than moved, and the overhead of each HTTP request often outweighing its payload. It moved its delivery-partner and customer apps to persistent MQTT connections, with automatic reconnection that restores subscriptions.

    Eternal (Zomato): Pulse, building resilient MQTT infrastructure for Android (2026) ↗

In the interview

Follow-up questions

A rider rides through a tunnel for two minutes. What does the customer see, and what happens when the signal returns?
The last known position, marked with its age ('updated 1 min ago'), and an estimate from the delivery-time model. When the phone reconnects it may upload a burst of positions: store them all in the trail, but push only the newest to the customer, since older positions are worthless on a live map.
How does the fan-out service know which gateway holds a given customer's connection?
Either a registry (order or user id to gateway id, in memory, refreshed by gateway heartbeats and expiring when they stop), or a pub/sub channel per user that only the gateway holding the connection subscribes to. The registry is cheaper at huge scale; per-user channels are simpler to build.
At peak the stream falls 30 seconds behind. What do you do?
Positions 30 seconds old are useless, so consumers should skip to the newest position per order rather than replay every one. Keep status changes on a separate stream so they are never stuck behind positions. Then add partitions and consumers, and alert on lag before customers notice.

Your turn

Check yourself

Version 2 moved positions out of the database. Why does it still break at the dinner peak?

Why partition the position stream by order id rather than by city?

A gateway restarts and drops 20,000 connections. What should the apps do?

Sources: Uber Engineering: Uber's Real-Time Push Platform (2020) ↗ · Wolt: From Polling to WebSockets: Improving Order Tracking User Experience (2023) ↗ · Eternal (Zomato): Pulse, building resilient MQTT infrastructure for Android (2026) ↗ · Report a problem

A typical design, informed by public write-ups, not any one company's exact system. Diagrams are our own. Numbers are illustrative. All wording is original and paraphrases the linked sources.