← Back to All Questions
Very Hard~60 minAdvertising & Ads

Design Ads Serving System

GoogleMetaAmazonTwitterTikTok

📝 Problem Description

Design an advertising system that serves targeted ads in real-time. Handle ad selection, bidding, targeting, tracking, and billing at scale.

👤 Use Cases

1.
User wants to loads page so that sees targeted ads
2.
Advertiser wants to creates campaign so that ads start serving
3.
System wants to runs auction so that winner ad displayed
4.
User wants to clicks ad so that event tracked, billed

✅ Functional Requirements

  • Serve ads based on targeting criteria
  • Real-time bidding (RTB)
  • Frequency capping
  • Budget pacing
  • Click/impression tracking
  • Conversion attribution
  • Advertiser dashboard

⚡ Non-Functional Requirements

  • Ad selection < 100ms
  • Handle 1M ad requests/sec
  • 99.99% availability
  • Billing accuracy 100%

⚠️ Constraints & Assumptions

  • Latency is critical (affects revenue)
  • Fraud detection needed
  • Privacy regulations (GDPR)

📊 Capacity Estimation

👥 Users
1B daily users, 10M advertisers
💾 Storage
100TB (ads, events, logs)
⚡ QPS
Ad requests: 1M/sec, Clicks: 10K/sec
📐 Assumptions
  • 1B daily ad impressions (~12K/sec)
  • 1M ad requests per second at peak
  • 1% CTR = 10M clicks/day (~115/sec)
  • Average CPM: $5 (revenue: $5M/day)
  • 10M active campaigns
  • Average 100 ads per campaign = 1B ad creatives

💡 Key Concepts

CRITICAL
eCPM
Effective CPM = bid × predicted_CTR × 1000.
HIGH
Second-Price Auction
Winner pays second-highest bid + $0.01.
HIGH
Frequency Capping
Limit impressions per user per time window.
HIGH
Budget Pacing
Spread budget evenly over campaign duration.

💡 Interview Tips

  • 💡Start with the ad serving flow: request → selection → rendering
  • 💡Discuss the auction mechanism in detail
  • 💡Emphasize latency requirements (<100ms)
  • 💡Be prepared to discuss CTR prediction models
  • 💡Know the tradeoffs between user experience and revenue
  • 💡Understand programmatic advertising and RTB