KatInterview

Real-Time Ad Click Deduplication System

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsstreamingdeduplication

Last updated

Design a distributed system that ingests millions of ad clicks per second, eliminates duplicate events, and provides accurate near-real-time counts.

Problem

You need to architect a system that tracks advertising clicks at massive scale. The platform must ingest click events from users worldwide, remove duplicates reliably, and expose accurate aggregated counts with low latency for analytics dashboards.

Core Requirements

Functional Goals:

  • Accept click events containing ad identifiers and user identifiers
  • Eliminate duplicate clicks (both network retries and actual repeated user actions)
  • Serve queries that return total clicks for any ad within the past hour
  • Maintain data durability and counting accuracy

Scale and Performance:

  • Process 10 million click events per second globally
  • Acknowledge ingested events within 50 milliseconds
  • Reflect new clicks in query results within a few seconds
  • Handle duplicate detection correctly even during failures and retries

Expected Coverage

Your design should address:

  1. Interface contracts: What APIs do clients call to report clicks? What does the query endpoint return?
  2. Architecture: Trace the journey of a click event from arrival through storage, naming major components
  3. Duplicate handling: Explain your strategy for identifying and filtering both retry-based and user-based duplicates, including where deduplication state lives
  4. Scaling approach: How do you partition and distribute work to handle the throughput? How does the system remain available under component failures?

Hints

Hint 1

Think about the difference between a client retrying the same network request versus a user genuinely clicking twice—they require different treatment

Hint 2

Storing deduplication state locally within stream processors rather than in a remote cache can dramatically improve throughput

Hint 3

Use idempotent write patterns in your aggregation storage so that replaying events after a failure doesn't corrupt counts