Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

System Design (High-Level Design)  Module 29 – Case studies: platforms, analytics and developer tools

Design an ad click aggregator

Count ad clicks per ad and minute in event time, remove repeats and invalid traffic, and reconcile streaming totals with a daily recount for billing.

  • Advanced
  • 20 minutes
  • Examples run with Python 3.14.8, Pyodide 314.0.7, Node.js 24.21.0 and quickjs 0.32.0
  • By MySmartCoPilot
Free core, Pro depth: 7 of 20 minutes free
Free: Five questions decide how exact each number must be · The estimate: 30,000 clicks a second at the peak · A click id in every link, and three records · 3 more sections. With a pass: 3 in-depth parts and 3 interview answers, about 13 minutes.

What you will learn

  • Estimate click rates, raw storage and bandwidth for an ad-click pipeline
  • Remove repeated deliveries of clicks by click id at high rates
  • Aggregate clicks per ad and minute in event time, with late clicks handled
  • Check streaming totals against a batch recount of the raw clicks for billing

Before you start

An ad network records 864 million clicks a day, and two readers want different things from them. Advertisers watch dashboards that should change within seconds, and they pay invoices that must count every valid click exactly once.

The design that serves both keeps every raw click in an append-only log and reads that log twice. A streaming job removes repeated deliveries by click id, drops traffic that known-bot lists catch, and adds each click to the minute in which it happened, not the minute in which it arrived, so dashboards stay fresh. A daily recount reads the same raw clicks again, applies rules that need a whole day of data, and produces the numbers that are billed; any difference between the two is explained before an invoice goes out.

Five questions decide how exact each number must be

Ask what each number is used for, because that decides how exact it must be. The second column holds the answers this case study assumes:

Question Assumed here
Does a click pass through our own redirect, or does an app report it? Web clicks do; apps send theirs in batches, sometimes hours late
What is a duplicate: one click delivered twice, or two clicks by one person? A signed token per impression carries a click id; a second click on it counts once
How fresh must a dashboard be? A minute of lag
How late can a click arrive? Hours, from phones that were offline
Which numbers are billed, and for how long can they be disputed? Invoices are monthly, from daily totals that can be recounted

Functional:

  1. Record a click and send the person on to the advertiser’s page.
  2. Show clicks per ad, campaign and advertiser per minute, by country and device, for any time range.
  3. Produce the billed clicks of each advertiser per day, with invalid clicks removed.
  4. Correct published counts when late clicks or newly found invalid traffic change them.

Non-functional:

  • Fast redirects: counting never slows the redirect down.
  • No lost clicks: a click the service has acknowledged survives the failure of any one machine.
  • Fresh dashboards: a click shows up within a minute.
  • Exact bills: each valid click is billed once, and every billed number can be recounted from raw data.

The Media Rating Council’s invalid-traffic standard shapes the last requirement. It says that invalid traffic found through lists and routine checks “must be removed from monetized counts”, and that when a new kind is found, the counts of at least the 14 days before the discovery are checked again (Media Rating Council). So raw clicks must be kept long enough to be counted again.

Checkpoint

Check: What each number is used for

  1. One question Which requirement makes the design keep raw clicks for at least 14 days?

    Choose one answer.

    Show the answer: One question

    Answer: When a new kind of invalid traffic is found, the counts of at least the 14 days before are checked again

    The Media Rating Council's standard says that when a new kind of invalid traffic is found, the counts of at least the 14 days before the discovery are checked again. Minute rows cannot be recounted with a new rule; raw clicks can, so they are kept at least that long (30 days in this design).

The estimate: 30,000 clicks a second at the peak

Assume 864 million clicks a day, the busiest hour at three times the average, 400 bytes for each raw click and 30 days of raw clicks kept for recounts:

The estimate sheet, from its assumptions Python · estimates/estimates.py
"""The ad-click aggregator's estimates from stated assumptions: change any of them and run it again."""
DAY = 86_400  # seconds

clicks_per_day = 864_000_000  # every click recorded, valid or not, across all ads
peak = 3  # the busiest hour against the day's average
event_bytes = 400  # one raw click: click id, ad, campaign, event time, country, device, flags
raw_days = 30  # raw clicks kept for recounts, audits and new invalid-traffic checks
ads_per_minute = 400_000  # different ads that get at least one click in a busy minute
row_bytes = 40  # one (ad, minute) row: the ids, the minute, valid and invalid clicks
dashboards = 10_000  # advertiser dashboards open at the peak
refresh = 10  # seconds between two refreshes of one dashboard
per_partition = 5_000  # clicks a second that one partition of the streaming job keeps up with

avg = clicks_per_day / DAY
top = avg * peak
raw_day = clicks_per_day * event_bytes
rows_day = ads_per_minute * 1_440

print(f"Clicks: {avg:,.0f} a second on average, {top:,.0f} in the busiest hour")
print(f"Raw clicks: {raw_day / 1e9:,.1f} GB a day, {raw_day * raw_days / 1e12:,.1f} TB kept for {raw_days} days")
print(f"Arriving at the peak: {top * event_bytes / 1e6:,.1f} MB/s ({top * event_bytes * 8 / 1e6:,.0f} Mbit/s)")
print(f"Minute rows: {rows_day:,} a day, {rows_day * row_bytes / 1e9:,.1f} GB a day")
print(f"Raw clicks against minute rows: {raw_day / (rows_day * row_bytes):,.0f} times the bytes")
print(f"Dashboard queries at the peak: {dashboards / refresh:,.0f} a second")
print(f"Partitions busy at the peak: {top / per_partition:,.0f} of {per_partition:,} clicks a second each")

Output

Clicks: 10,000 a second on average, 30,000 in the busiest hour
Raw clicks: 345.6 GB a day, 10.4 TB kept for 30 days
Arriving at the peak: 12.0 MB/s (96 Mbit/s)
Minute rows: 576,000,000 a day, 23.0 GB a day
Raw clicks against minute rows: 15 times the bytes
Dashboard queries at the peak: 1,000 a second
Partitions busy at the peak: 6 of 5,000 clicks a second each

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 estimates.py

The rates are moderate: 30,000 clicks a second at the peak is 12 MB/s, which six partitions of a streaming job can take at 5,000 clicks a second each. Storage is shaped by the raw data: 345.6 GB a day of raw clicks against 23 GB of minute rows, 15 times as many bytes. Counts are what dashboards read; the raw clicks are what billing trusts.

Checkpoint

Check the estimate

  1. Question 1 of 2 An ad network records 864 million clicks a day across all its ads. How many clicks a second is that on average?

    Type a number.

    A hint

    A day has 86,400 seconds.

    Show the answer: Question 1 of 2

    Answer: 10000 clicks a second (anything from 9000 to 11000 counts)

    864,000,000 ÷ 86,400 seconds = 10,000 a second. Clicks follow people's days, so the design is sized for the busiest hour, not for this average.

  2. Question 2 of 2 At the peak of 30,000 clicks a second, with 400 bytes for each raw click, how many megabytes a second of raw clicks arrive?

    Type a number.

    Show the answer: Question 2 of 2

    Answer: 12 MB/s (anything from 10.8 to 13.2 counts)

    30,000 × 400 bytes = 12 MB/s, about 96 Mbit/s. That is modest for a replicated log; the hard parts of this design are correctness and time, not bandwidth.

  • GET /c/{token}: the link behind every ad. The service checks the token’s signature, writes the click to the log and answers 302 Found, with the advertiser’s address in the Location header (RFC 9110).
  • POST /v1/app-clicks: apps send their queued clicks in batches, each with the token it was shown.
  • GET /v1/ads/{adId}/clicks?from=…&to=…&step=minute: counts for a dashboard.
  • GET /v1/advertisers/{id}/billing?month=…: billed clicks per ad and day, final once a day is closed.

Three records hold the data, each keyed for the path that reads it:

Record Key Holds
Raw click The click id, from the signed token The ad, campaign and advertiser, the event time (when the click happened), the arrival time, the country, the device class and the result of each check
Minute row An ad and a minute Its valid and invalid clicks; rolled up into hours after a week and into days after a month
Billing row An advertiser, an ad and a day Its billed clicks and the version of the recount that produced it

Checkpoint

Check: The click id and the three records

  1. One question Where does a click's id come from, so that a repeated delivery of the click carries the same id?

    Choose one answer.

    Show the answer: One question

    Answer: From the signed token in the ad's link, minted for each impression

    The id is part of the signed token behind each impression's link. Every delivery of one click carries it, so the stream and the recount can recognise repeats exactly, and a second click on the same impression counts once.

The high-level design, walked along one click

Clicks go through a click service into a log that a streaming job reads for dashboards and a daily recount reads for billing.Browser or appclicks an adClick servicechecks the signed token,logs the click, then redirectsClick lograw clicks, partitioned by ad,replicated, kept 7 daysStreaming jobrepeats out by click id, bot lists,counts per ad and minutein event timeColumnar store(ad, minute) rows,rolled up to hours and daysQuery APIfilters by country and deviceAdvertiser dashboardRaw archiveobject storage, 30 daysDaily recounteach click id once,rules that need a whole dayBillinginvoices from the recount,every difference explainedGET /c/{token}302 to theadvertiserraw clickminute rows,updated by late clicksranges and rollupscopied hourlybilled clickscorrections

The ad-click aggregator's high-level design

Text description of the diagram

The diagram runs from top to bottom.

  1. A person clicks an ad in a browser or an app, which sends GET /c/{token} to the click service.
  2. The click service checks the signed token, writes the raw click to the click log and then answers with a 302 redirect to the advertiser's page (a dashed arrow back to the person).
  3. The click log holds raw clicks, partitioned by ad, replicated and kept for 7 days.
  4. A streaming job reads the log. It removes repeated deliveries by click id, drops clicks that bot lists catch, and counts clicks per ad and minute in event time.
  5. The streaming job writes (ad, minute) rows to a columnar store, and updates them when late clicks arrive. The store rolls minutes up into hours and days.
  6. The query API reads ranges and rollups from the columnar store, filters them by country and device, and serves the advertiser dashboard.
  7. The click log is also copied hourly to a raw archive in object storage, kept for 30 days.
  8. A daily recount reads the raw archive, counts each click id once and applies rules that need a whole day of clicks.
  9. The recount sends billed clicks to billing, which invoices from the recount and explains every difference from the streaming totals. A dashed arrow from the recount back to the columnar store carries corrections.

Step through one made-up click, k42 on ad-7, along the four paths:

Interactive · step by step One click along the four paths Step through one click from the person who makes it to the bill it ends up on. Each step names the part that acts and what it keeps.
One click along the four paths, step 12 of 12. Showing Browser or app, Advertiser's page, Click service, Click log (k42, ad-7, 10:00:05), Streaming job (ad-7, 10:00: +1), Raw archive, Columnar store, Daily recount, Query API, Billing, Dashboard. In focus: Click log.GET, then 302follows the redirectraw clickread in ordercopied hourlyminute rowsbilled clickscorrectionsBrowser or appAdvertiser's pageClick servicechecks the signed tokenClick logk42, ad-7, 10:00:05Streaming jobad-7, 10:00: +1Raw archiveobject storage, 30 daysColumnar storeminute rowsDaily recounteach click id onceQuery APIranges and rollupsBillingDashboard

The drawing shows the whole scene; its 12 steps are listed below.

Every step as text
  1. The click. A person clicks an ad for ad-7 at 10:00:05. The link behind the ad is the click service with a signed token, so the browser sends GET /c/{token}.
  2. Checked, then logged. The click service checks the token's signature and takes the click id, k42, from it. It appends the raw click to the click log and waits until the log has it.
  3. Then redirected. Only now does the service answer 302 Found, with the advertiser's address in the Location header. Nothing on this path counts anything, so counting can never slow a redirect.
  4. The person moves on. The browser follows the redirect to the advertiser's page. Everything after this reads the click log, later.
  5. The stream reads the click. The streaming job reads k42 in log order. It has not seen that id before and no bot list names the source, so it adds one click to ad-7 for 10:00, the minute in which the click happened.
  6. The minute is published. Once the watermark passes 10:01, the job writes the row for ad-7 and 10:00 to the columnar store. A late click for that minute updates the row later.
  7. A dashboard reads rows. The advertiser's dashboard asks the query API for the last hour. The API reads minute rows, never raw clicks, and hour or day rows for longer ranges.
  8. Copied to the archive. Every hour the click log is copied to object storage, where raw clicks stay for 30 days, long enough to recount any day an advertiser disputes.
  9. The day is recounted. Once the day is closed, the recount reads the archive: k42 is counted once however many times it was delivered, with the same bot lists and rules that need a whole day of clicks.
  10. Billed from the recount. The recount's totals go to billing; they are the numbers on the invoice.
  11. Differences flow back. Where the recount differs from the stream's minute rows, it writes corrections to the columnar store, so dashboards end the day on the billed numbers.
  12. One log, read twice. Only the click service and the click log were on the person's path. The stream and the recount both read the same raw clicks, one for fresh counts and one for exact ones.

The write path. The click service checks the token, appends the raw click to the click log and only then redirects, so an acknowledged click is never lost. The log is partitioned by ad and replicated. Nothing on this path counts anything, so a slow aggregation never slows a redirect.

The streaming path. A streaming job reads the log, removes repeated deliveries by click id and drops clicks from known bots and data-centre addresses. It adds each remaining click to its ad’s count for the minute it happened. When its watermark (stream processing): A stream job's running estimate of how far event time has progressed. When it passes the end of a window, the window's result is emitted, and an event for that window that comes afterwards is late. More in “Stream processing: windows, event time, watermarks”, its estimate of how far event time has progressed, passes the end of a minute, it writes that minute’s rows to a columnar store, and it updates them when late clicks arrive.

The read path. Dashboards ask the query API, which reads minute rows for recent ranges and hour or day rows for long ones, never raw clicks.

The billing path. The log is copied to object storage every hour. Once a day is closed, a batch job recounts it: each click id once, the same lists, and rules that need a whole day, such as a device that clicked one advertiser’s ads a hundred times. Its totals are billed, and every difference from the streaming totals is explained.

Checkpoint

Check: The four paths of one click

  1. Question 1 of 2 Which of these must work for a click to be recorded and the person sent on to the advertiser's page?

    Choose every answer that is right.

    Show the answer: Question 1 of 2

    Answer:

    • The click log
    • The click service

    The click service checks the token, appends the click to the log and only then redirects. Everything else reads the log later, so a slow or failed streaming job, store or recount delays counts but never loses a click or slows a redirect.

  2. Question 2 of 2 Which of these come from the daily recount rather than from the streaming job?

    Choose every answer that is right.

    Show the answer: Question 2 of 2

    Answer:

    • The clicks billed to each advertiser for a day
    • Corrections to minutes that were already published

    The streaming job publishes each minute quickly; the recount reads a closed day of raw clicks, removes every repeat and applies rules that need the whole day, so its totals are billed and its differences correct the dashboards.

Practise: the first design, one question at a time

Practise the four ideas above, the weakest first:

Practice that adapts to you

Practise this lesson

13 questions about 11 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 13 Dashboards may lag by a minute, but bills must be exact. Which design follows from those two answers?

    Choose one answer.

    Show the answer: Question 1 of 13

    Answer: Publish counts quickly from a stream, and bill from a recount of the raw clicks

    Freshness and exactness pull in opposite directions, so the design keeps raw clicks in a log and reads it twice: a streaming job for dashboards that may lag by a minute, and a daily recount for the bills.

  2. Question 2 of 13 In this design, what counts as a duplicate click?

    Choose one answer.

    Show the answer: Question 2 of 13

    Answer: A second click on the same impression, which carries the same click id

    The answers assumed here make a duplicate one click delivered or made twice on the same impression. The click id in the impression's signed token recognises it; clicks by one person on other impressions are separate clicks.

  3. Question 3 of 13 On the 20th day of a month, a new kind of invalid traffic is found. Which counts must be checked again, and from what?

    Choose one answer.

    Show the answer: Question 3 of 13

    Answer: At least the 14 days before the discovery, recounted from the raw clicks

    Invalid traffic found later means rechecking at least the 14 days before its discovery. Only raw clicks can be recounted with a new rule, which is why they are kept for 30 days, beyond the look-back.

  4. Question 4 of 13 Which rate sizes the click service, the log and the streaming job?

    Choose one answer.

    Show the answer: Question 4 of 13

    Answer: The busiest hour, 30,000 clicks a second

    864 million clicks a day are 10,000 a second on average and 30,000 in the busiest hour, three times the average. The click path is sized for 30,000, which is 12 MB/s and six busy partitions at 5,000 clicks a second each.

  5. Question 5 of 13 The busiest hour runs at 3 times the day's average of 10,000 clicks a second. At 5,000 clicks a second per partition of the streaming job, how many partitions are busy at the peak?

    Type a number.

    Show the answer: Question 5 of 13

    Answer: 6 partitions

    3 × 10,000 = 30,000 clicks a second, and 30,000 ÷ 5,000 = 6 partitions busy. The log is split into many more than six, for headroom and for the day an ad goes viral.

  6. Question 6 of 13 Each raw click takes 400 bytes in the log. How much raw click data arrives in a day of 864 million clicks, in GB?

    Type a number.

    Show the answer: Question 6 of 13

    Answer: 345.6 GB a day (anything from 311 to 380.2 counts)

    864,000,000 × 400 bytes = 345.6 GB a day, about 10.4 TB for 30 days. Raw clicks are kept so that bills can be recounted and checked, which is why they are kept far longer than any dashboard needs them.

  7. Question 7 of 13 In a busy minute, 400,000 different ads get at least one click, and each (ad, minute) row takes 40 bytes. How much do a day's minute rows take, in GB?

    Type a number.

    Show the answer: Question 7 of 13

    Answer: 23.04 GB a day (anything from 20.74 to 25.34 counts)

    400,000 × 1,440 minutes × 40 bytes ≈ 23 GB a day, 15 times less than the raw clicks. Dashboards read these rows, never the raw clicks.

  8. Question 8 of 13 Minute rows take 23 GB a day and raw clicks 345.6 GB. Why does the design keep 30 days of raw clicks at all?

    Choose one answer.

    Show the answer: Question 8 of 13

    Answer: Bills must be recountable, and a new kind of invalid traffic means rechecking past days from raw clicks

    Counts are what dashboards read, and raw clicks are what billing trusts: 10.4 TB for 30 days buys recounts, disputes answered from data, and the 14-day look-back for invalid traffic found later.

  9. Question 9 of 13 A phone records a click at 09:59:50 and sends it at 10:03:00. Which times does the raw click hold, and which minute counts it?

    Choose one answer.

    Show the answer: Question 9 of 13

    Answer: Both times; it is counted in the 09:59 minute, its event time

    The raw click keeps both the event time, when the click happened, and the arrival time. The streaming job adds it to the minute it happened, 09:59, and updates that minute if it was already published.

  10. Question 10 of 13 Which record does an advertiser's dashboard read?

    Choose one answer.

    Show the answer: Question 10 of 13

    Answer: Minute rows, with their hour and day rollups for long ranges

    A minute row holds an ad, a minute and its valid and invalid clicks; rollups into hours and days keep long ranges cheap. Dashboards read those, and billing reads the billing rows of the recount.

  11. Question 11 of 13 Why does a billing row hold the version of the recount that produced it?

    Choose one answer.

    Show the answer: Question 11 of 13

    Answer: A later recount, after new invalid traffic is found, can issue credits against the version that was billed

    Bills can change after they are sent, when a new pattern of invalid traffic is found within the look-back. Versioned billing rows keep every recount's result, so a credit names exactly what it corrects.

  12. Question 12 of 13 The streaming job is down for 20 minutes at the peak. What happens to redirects, dashboards and bills?

    Choose one answer.

    Show the answer: Question 12 of 13

    Answer: Redirects are unaffected, dashboards pause and then catch up, and bills are unaffected

    The log decouples the click path from the counting. While the job is down, clicks pile up in the log; the job reads them when it returns, dashboards catch up, and the recount bills the day as usual.

  13. Question 13 of 13 Where do the corrections that bring a dashboard to the billed numbers come from?

    Choose one answer.

    Show the answer: Question 13 of 13

    Answer: The daily recount, which writes its differences back to the columnar store

    The recount produces the billed totals and sends its differences from the stream back to the columnar store as corrections, so each day's dashboard ends on the numbers on the invoice.

The deep dives this design must answer

The choices left open at each step:

  • Removing repeats: an exact store keeps recent click ids and decides every delivery. A Bloom filter answers “maybe seen” from a few bits per id, and is sometimes wrong.
  • Late clicks: the job can drop a late click, update a published minute within an allowed lateness, or send the click to a correction path.
  • Exact totals: a recount reads raw clicks again. A transactional sink writes results with their log positions. An idempotent write ignores what it already has.
  • Serving: a columnar store with rollup tables answers range queries. Counters in a key-value store answer one key fast but scan ranges slowly.

The deep dives answer six questions: removing repeats without dropping valid clicks, invalid clicks, how wrong a first count is, one popular ad, closing a day, and ten and a hundred times the load.

Repeated deliveries and invalid clicks, removed and measured Pro: opens with a Pro, Premium or Ultimate pass

A click can reach the log more than once, and it can come from something that is not a person; both inflate a bill. This part measures what an exact store of click ids and a Bloom filter each cost and miss, and sorts invalid traffic into what the stream can catch and what only a recount can.

In this part:

  • Where repeats come from, and what removing them costs, with numbers
  • Invalid traffic: lists in the stream, day-long rules in the recount

1 runnable example (Python) · about 10 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Read a complete sample first: Design a real-time leaderboard

Counting minutes in event time: watermarks, late clicks and a hot ad Pro: opens with a Pro, Premium or Ultimate pass

A minute’s count can be published quickly or completely, never both, so the design publishes early and corrects later. This part measures how wrong first results are for four watermark bounds, what allowed lateness costs in state, and how to split an ad that suddenly takes 40 % of all clicks.

In this part:

  • How wrong a minute’s first count is, by watermark bound, measured
  • Allowed lateness and the correction path, with the state each costs
  • A hot ad split over eight sub-keys, worked through

1 diagram · 2 runnable examples (Python) · about 11 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Closing the day for billing: reconciliation, failure drills and levels Pro: opens with a Pro, Premium or Ultimate pass

An invoice must be explained click by click, which a streaming total cannot do on its own. This part reconciles a day of streaming totals with a recount, drills the failures behind each kind of difference and sets out what each level of candidate is expected to cover.

In this part:

  • Streaming totals against a recount, every difference explained
  • Which guarantee each stage gives, end to end
  • Failure drills
  • What breaks at ten and a hundred times the load
  • Options considered and rejected
  • What each level is expected to cover

1 diagram · 1 runnable example (Python) · about 10 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Interview questions

  1. Fresher to mid · Warm-up

    Why does every ad click need its own id, and where in the pipeline are repeated deliveries removed?

    Logs and queues deliver at least once: a browser resends a click whose answer it never saw, and a consumer that restarts reads everything after its last committed position again. Without an id, a repeated delivery looks exactly like a second click and is billed twice. Put the id in the signed token of the ad's link, minted for each impression, so every delivery of one click carries the same id and nobody can invent new ones; two clicks on one impression then count once. Remove repeats twice: the streaming job skips ids it has seen recently, which keeps dashboards close to right, and the daily recount counts each id once over the whole day, which makes the bill exact.

  2. Mid to senior

    App clicks can arrive hours late, dashboards must show each minute within a minute, and invoices must be exact. How do you count clicks per ad and minute, and what happens to a click that arrives after its minute was published?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  3. Senior to staff

    When a day closes, the streaming total for one advertiser is 10 % higher than the recount from raw clicks, and two others are slightly lower. How do you work out why, which number do you bill, and what do you change?

    Model answer, Pro. First step and follow-ups

  4. Mid to senior

    A single ad goes viral and takes 40 % of 30,000 clicks a second. Your log and streaming job are partitioned by ad id, and one partition processes 5,000 clicks a second. What breaks, and how do you fix it without wrong counts?

    Model answer, Pro. First step and follow-ups

Key takeaways

  • Ask what each number is used for: dashboards need fresh counts, bills exact ones, kept recountable for 14 days.
  • At 864 million clicks a day the peak is 30,000 a second, and raw clicks take 15 times the bytes of minute rows.
  • A click id in the signed token of every ad link makes a repeated delivery recognisable.
  • Keep every raw click in a log and read it twice: a stream counts minutes in event time, a daily recount bills.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.