Design a Shipment Tracking System
Understanding the Problem
📦 What is a shipment tracking system? A shipment tracking system follows a parcel from the moment a label is printed until it's delivered. Every time the package is picked up, scanned into a sorting hub, loaded onto a truck, handed to another carrier, cleared through customs or dropped on a porch, someone records an event. The system turns that stream of events into what customers see on a carrier's tracking page: a current status, a timeline of where the package has been, an estimated delivery date, and notifications along the way.
You'll hear this as "design UPS tracking," "design a package tracking system" or "design a logistics platform where many parties update a shipment." They're the same problem. The interesting part is the multi-party aspect: events come from the carrier's own scanners and driver apps, but also from partner carriers, last-mile delivery partners, customs brokers and airlines, each with its own format, timing and reliability. We'll design a carrier's tracking platform and cover partner and multi-carrier tracking in the deep dives.
Functional Requirements
Core Requirements
- Shippers should be able to create a shipment and get a tracking number.
- The system should accept tracking events from every party that handles the package: hub scanners, driver apps and partner carriers.
- Users should be able to look up a tracking number and see the current status, the location history and an estimated delivery date, plus the driver's live location when the package is out for delivery.
- Users and shippers should be able to subscribe to updates (email, SMS, push, or webhooks for shippers).
Below the line (out of scope)
- Route optimization and network planning.
- Billing, rating and label pricing.
- Warehouse management and customs paperwork.
- Claims for lost or damaged packages.
Non-Functional Requirements
Ask your interviewer how big the carrier is. For our design: 30 million new shipments a day, about 15-20 tracking events per package over its life, 100,000 delivery drivers on the road during the day, and holiday peaks of 2-3x normal volume.
Core Requirements
- Once an event is accepted, it must never be lost. Tracking events are also the legal record of custody and delivery.
- Status should reflect a new event within about a minute.
- Tracking lookups should return in under 200 ms and stay available even if event processing is behind.
- The system must produce the right status even when events arrive late, out of order or duplicated.
- Ingestion must keep working through traffic spikes and through network outages at hubs.
Below the line (out of scope)
- Multi-region active-active for a single package's writes. Each package's events are processed in one region.
Back-of-the-envelope:
- Events: 30M packages × ~17 events is about 500M events a day, roughly 6,000 per second on average. Hubs sort in waves (overnight and evening), so peaks are several times that, and holiday peaks push it to 30,000-50,000 per second.
- Storage: at ~500 bytes per event, 500M events is about 250 GB a day, roughly 90 TB a year before replication.
- Reads: if each package is looked up about 5 times by people, that's 150M lookups a day, under 2,000 per second on average. Shippers polling the API for status can easily be several times that.
- Driver GPS: 100,000 drivers sending a location every 15 seconds is about 6,700 pings per second during delivery hours.
The shape that matters: this is write-heavy and append-only, with reads concentrated on the current state of one package. That points to an event log plus a per-package projection, keyed by tracking number, rather than a relational schema we update in place.
The insight interviewers look for: a package's status is not something anyone writes directly. It's derived from events that come from many parties, often late and out of order. Store the events as the source of truth, and compute status from them.