Skip to the guide

Design an ad click aggregator

AdvancedCase study12 pages

We record each click on an ad and send the person on to the advertiser's page. The advertiser sees her clicks per minute within a couple of minutes, and pays monthly for every valid click once. It's a taxi meter that both sides watch: the passenger sees it tick, but she pays what the printed receipt says.

It's also asked as "design click counting for Google Ads". The closest case study is Top-K and trending, which counts views in windows but bills nobody. Interviewers like it, and candidates report Meta asking it (prep sites, 2025), because money rides on a count whose events arrive late, twice, or from a bot. Real-time aggregation teaches the stream job, watermarks and recount, so this page spends its time on what makes a click billable.

Below is a full mock interview following the seven steps of the framework. You're the candidate: at each Guess before you read on, stop and answer first.

Step 1 · Clarify the features and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design an ad click aggregator.

You: Where do clicks come from: a redirect through our servers, or an SDK inside apps?

Interviewer: Both. Web clicks go through our redirect, and our SDK in publishers' apps reports clicks in batches.

You: What does the advertiser see, and how fresh?

Interviewer: Clicks and spend per ad and campaign, by minute, country and device, within a couple of minutes. Any range over the last two years.

You: Advertisers pay per click, and publishers earn a share?

Interviewer: Yes to both, with monthly invoices.

You: Do we decide which clicks are invalid, such as bots?

Interviewer: Yes. Invalid clicks are never billed.

You: Then I'll cover click capture and the redirect, dropping repeats, live counts, the billed counts and invalid clicks. Out: the ad auction, conversions, payments, and impressions, which another team counts with the same design at a hundred times the volume. OK?

Interviewer: Go ahead.

Each answer shapes the design: the redirect sits in the user's way, app batches arrive late and twice, and billing needs a count we can reproduce.

Step 2 · Non-functional requirements

Minutes 5–8 · How this step works

You: Say 400 million clicks a day, the ad network of Batch vs stream processing, and windows: ~4,600 a second on average and 10,000 at peak. Our part of a redirect takes under 50 ms at p99, and redirects are 99.99% available. A minute's clicks reach the dashboard within two minutes, and dashboard queries answer within a second at p99. We bill at most one click per impression and never an invalid one, and any invoice can be recomputed from the raw clicks for 13 months. When in doubt, we under-bill.