Design Advertising Order Lifecycle Tracking
Design the data model and services that track an advertising order's versioned configuration, lifecycle, delivery, and spend progress.
Problem statement
For this exercise, assume a demand-side advertising platform lets an advertiser create an order containing one or more line items, activate or pause delivery, and inspect current delivery and spend progress.
An order belongs to one advertiser account, uses one currency, and moves through DRAFT, ACTIVE, PAUSED, COMPLETED, or CANCELLED states. Configuration edits create an immutable order version and require the caller's expected current version; historical delivery remains attributed to the version active when it occurred.
Delivery systems publish immutable events with a stable event ID, order ID, line-item ID, order version, event time, delivered-impression count, and spend amount.
Retries must not count one event twice, events may arrive up to twenty-four hours late or out of order, and corrections use explicit reversal or adjustment events instead of rewriting history.
The event ledger is authoritative for delivered and spent totals; query projections may lag but must return an as-of watermark and expose rebuilding state rather than silently mixing incomplete data.
Design for two million active orders, twenty million active line items, one hundred thousand delivery events per second, and ten thousand order-progress reads per second.
Healthy configuration writes should complete within 500 milliseconds at p95, common order reads within 300 milliseconds at p95, and 99 percent of accepted delivery events should appear in progress within 60 seconds.
Retain immutable delivery events for thirteen months, and preserve acknowledged configuration changes and events through a single-zone failure. Exclude ad auctions, bid optimization, creative storage, targeting, frequency capping, invoice generation, payments, and cross-currency conversion.
What to build
- An advertiser can create an order, version its line-item configuration, and inspect the current authoritative version.
- An advertiser can activate, pause, complete, or cancel an order through validated retry-safe state transitions.
- Delivery systems can append retry-safe impression and spend events, including explicit corrections, without double counting.
- An advertiser can read order and line-item delivery and spend progress with configuration version, freshness watermark, and rebuild status.
At scale
- For this exercise, assume two million active orders, twenty million active line items, one hundred thousand delivery events per second, and ten thousand order-progress reads per second.
- For this exercise, target 500 milliseconds p95 for healthy configuration writes, 300 milliseconds p95 for common order reads, and make 99 percent of accepted events visible in progress within 60 seconds.
- For this exercise, allow delivery events to arrive up to twenty-four hours late or out of order, use explicit adjustment events for corrections, and retain the immutable event ledger for thirteen months.
- For this exercise, acknowledged order changes and accepted delivery events survive a single-zone failure, while projections expose an as-of watermark and rebuild state when incomplete.