← Create New Paste

Designing a Package Tracking Service for Shipments (System Design Interview)

6 views
"Design a package tracking system like the ones carriers and online stores use" is a practical system design prompt. It combines high-volume event ingestion, a simple but heavily read status view, and notifications. It also leaves room to discuss data modeling, idempotency, and partner integrations. Requirements Functional: every shipment gets a tracking number; scan events (picked up, arrived at facility, departed, out for delivery, delivered, exception) are recorded with time and location; customers see the current status and history; customers can subscribe to email, SMS, or push notifications; merchants can query in bulk or receive webhooks. Non-functional: millions of shipments per day and several scan events each; reads far exceed writes, especially around holidays and delivery days; events may arrive late, duplicated, or out of order; status pages should load in under 200 ms. Data model Shipments table: tracking_number (primary key), merchant_id, origin, destination, service level, estimated delivery date, current_status, last_event_time. Events table: tracking_number, event_id, event_type, timestamp, facility or location, source. Partition by tracking_number so a shipment's history is stored together, and sort by timestamp within it. A wide-column store such as Cassandra or a sharded relational database both work; discuss the choice briefly. Ingestion pipeline Scanners in facilities, driver handheld apps, and partner carriers send events to an ingestion API, which validates them and writes to a durable log such as Kafka, keyed by tracking_number so events for one package are processed in order by the same consumer. A processor deduplicates by event_id (devices retry on bad connectivity), appends the event, and updates current_status. Out-of-order events are the interesting part. A "delivered" event might arrive before a delayed "out for delivery" scan. Store every event, but derive current_status from the event with the latest timestamp and a status ranking, so a late-arriving earlier event never moves a delivered package back to in transit. Read path The tracking page needs the shipment row plus recent events. Cache the rendered status in Redis keyed by tracking_number, invalidated or updated by the processor on each new event. A CDN can cache the public page for a short time. Bulk merchant queries go through a separate API with rate limits so they don't compete with consumer traffic. Notifications and ETAs The processor emits status-change events to a notification service, which looks up subscribers and sends messages with idempotency keys to avoid duplicates. Estimated delivery can start as a rule (service level plus route) and later use a model trained on historical transit times. Scale and reliability Holiday peaks can be 5-10x normal, so autoscale consumers and keep the log's retention long enough to replay. Archive delivered shipments' events to cheaper storage after a few months. Wrap-up Summarize the main trade-offs: eventual consistency in exchange for throughput, and status derivation rules that tolerate messy real-world scan data. Rehearse explaining designs like this one aloud. Linkjob AI (https://linkjob.ai) provides real-time help during live job interviews and technical interviews when you want support staying organized in a system design round.
Created Nov 17, 2026 14:32 Expires Nov 17, 2027 14:32