Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 55

Design ad delivery for a social feed

Expert · 60 min · Search & ranking

Businesses create ad campaigns with a daily budget, a bid, a target audience and a creative. As people scroll their feed, every few posts there is an ad slot, and the system has to choose which ad (if any) to show, charge the right advertiser for what was actually seen, and keep each campaign spending smoothly through the day.

Requirements

  • Advertisers create and edit campaigns: daily budget, schedule, bid per thousand impressions or per click, targeting (location, age range, interests) and creatives that pass review.
  • When the feed requests ads for a viewer, return eligible ads ranked by an auction that combines bid and predicted engagement, within the latency budget.
  • Enforce frequency caps (for example at most 3 impressions per user per campaign per day) and pace spend so a daily budget lasts the whole day.
  • Record impressions and clicks once each for billing, and show advertisers their spend within minutes.

Constraints and assumptions

  • 1 million active campaigns with 5 million ads; targeting and budgets change many times a day.
  • Peak 200,000 ad requests per second, each filling 2 to 3 slots; ad selection p99 under 50 ms.
  • Peak 300,000 impressions and 3,000 clicks per second.
  • A campaign may overspend its daily budget by at most 2%, and anything beyond the budget is never billed.
  • Advertiser reports may lag by up to 5 minutes; billing must be exact.

Out of scope for the first sketch

Training the click prediction model · Invoicing and payment collection · Conversion tracking beyond clicks

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches