Design a Ads Management and Delivery
Design the ads system of a social app. Advertisers create campaigns with a budget, a schedule, targeting such as country, age and interests, a bid and one or more ads. When a user scrolls their feed, the feed service asks us for ads to place between posts. We choose the ads that are best for the user, the advertiser and the business, record what was shown and clicked, charge the advertiser, and report results back to them.
The app has 500 million daily users, which means about 300,000 ad requests a second at peak, 420,000 impressions a second, 5 million active ads and about $70 million of spend a day. The hard parts: the feed waits for us, so a decision over millions of ads has 80 ms; budgets must stop on time across dozens of servers without a single hot counter; every impression is money, so each must be counted exactly once despite retries and bots; and advertisers expect to see their results within a minute.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Which ad formats?
- 2How do advertisers pay?
- 3How exact must budgets be?
- 4What counts as an impression?
- 5How fresh must reports be?
- 6How fast must changes go live?
- 7Who reviews ads?
- 8What about privacy?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives: budgets, auction, billing