Design a Flight Deal Notification Service
Find good flight offers by city and deliver live and historical deals once per traveler.
Problem statement
Design a flight-deal email notification service. Travelers subscribe to destination cities and receive good flight offers without receiving the same deal twice. A new subscriber must also receive still-eligible deals that were found before they subscribed.
A Flights Crawler API accepts the cities to inspect and returns flight offers; a Deal Decider API tells you whether an offer is a good deal; a Notification API sends messages. These three external capabilities are supplied. Do not design the crawler, the deal-scoring model, booking, or multi-leg itinerary search.
For this exercise, assume each subscription belongs to one authenticated traveler, names one destination city, and has an active or cancelled state. Each offer has a stable provider offer ID, a version, price, currency, observation time and expiry. The supplied decider evaluates a specific offer version.
Active offer snapshots, eligible episode state and their delivery identities remain durable for the entire eligibility lifetime, even when the raw observation history has expired.
An eligible deal episode begins when an offer first qualifies and ends when it expires or stops qualifying; a later qualifying episode has a new identity. Deliver at most one email per traveler and episode, even when several subscriptions match.
New subscriptions backfill all unexpired qualifying episodes at their creation cutoff; after that cutoff they receive live matches. Authorize a new send only when the current episode is still open and qualifying, is unexpired, and has an active matching subscription.
Cancellation prevents new delivery authorizations after its commit; an already authorized send may still complete and its outcome must be shown accurately.
For this exercise, use one region with multiple zones. External APIs have quotas and may fail or time out. The notification provider durably deduplicates an idempotency key for the full retained delivery lifetime and supports status lookup under that key.
A timeout is an uncertain outcome that must be reconciled under the same key. Explain the weaker guarantee if that provider contract is unavailable. Persist sufficient price history to explain a deal and choose a refresh schedule that balances freshness, provider quotas and rapidly changing prices.
Apart from the stated offer and provider contracts, the product quantities and guarantees below are exercise assumptions rather than additional interview facts.
What to build
- A traveler can create, inspect and cancel destination-city subscriptions and see their activation and backfill status.
- The service schedules city fetches within external quotas, retains relevant price observations, and records versioned qualification and expiry of flight-deal episodes.
- Active travelers receive one logical email per eligible deal episode through both historical backfill and live matching, with durable delivery status and cancellation semantics.
At scale
- For this exercise, assume 10 million active travelers, 20 million city subscriptions, 10,000 destination cities and 100,000 accepted offer updates per second at the normal peak.
- For this exercise, make 99 percent of normal-peak eligible deal episodes visible to healthy-provider delivery within five minutes of acceptance; backfill is separately rate limited and shows progress.
- For this exercise, retain raw price observations for seven days while keeping active offer snapshots and eligible episodes until eligibility ends. Keep closed episode history for 30 days after closure. Keep delivery identities and provider deduplication keys for at least 90 days after closure and until every uncertain send has a definitive reconciled outcome, whichever is later; never authorize a new send for an already expired episode.
- The reported stress follow-up asks about 10 billion deals in ten minutes. Analyze its storage, partitioning and backlog separately from the normal peak, stating record sizes and external drain limits before claiming a completion time.