Design advertising frequency caps and the advertising-order data model
Company: Netflix
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
Design an advertising frequency-cap system and the tables used to represent advertising orders. Explain how an impression request is checked against the relevant cap and how the order model connects advertisers, delivery rules, and creatives.
### Clarifying Questions
- Is the cap per user and ad, campaign, order, advertiser, or another scope?
- Does the window use a fixed calendar interval or a rolling duration?
- Is the counted event an ad selection, a delivery attempt, or a confirmed impression?
- Must the cap be strict across regions, and how should anonymous identity, retries, and late impression events behave?
### Part 1: Enforce frequency limits
Define the admission and accounting flow for a configurable limit N within a window W. Handle simultaneous requests, duplicate events, and delayed confirmation.
```hint Separate a decision from an impression
Two requests may pass a check before either impression is recorded. Decide how pending delivery affects the remaining allowance.
```
#### What This Part Should Cover
- Identity and cap scope
- Atomic admission and duplicate handling
- Window semantics, pending delivery, and failure behavior
### Part 2: Model advertising orders
Design relational tables for advertising orders and their delivery configuration. Show how cap rules and impression records reference the entities being limited.
```hint Identify the rule owner
A cap attached to a creative behaves differently from a cap shared by all line items in one order.
```
#### What This Part Should Cover
- Order ownership, line items, creatives, and rule relationships
- Versioned configuration and identifiers for delivery accounting
- Indexes and separation of transactional configuration from high-volume events
### What a Strong Answer Covers
- Agreement between table relationships and the runtime cap scope
- A precise consistency guarantee with explicit regional trade-offs
- Observability and reconciliation of cap decisions and counted impressions
### Follow-up Questions
- How would you avoid exceeding a global cap when two regions serve the same user concurrently?
- How would a cap-rule change affect impressions already inside the window?
Overview: Design advertising frequency limits alongside an order, line-item, and creative data model. Define counted events, atomic admission, rolling windows, duplicate handling, regional consistency, and policy-version relationships.