Design a Streaming Top-K Hitters System
Continuously rank the most frequent keys over recent and all-time windows.
Problem statement
For this exercise, assume you are designing a streaming top-k hitters system. Continuously rank the most frequent keys over recent and all-time windows. Define a coherent first production version that satisfies the listed requirements and scale while making failures and degraded behavior visible.
What to build
- Accept high-volume key-hit events with event timestamps and idempotency identifiers.
- Return top K for configured windows and dimensions with counts and freshness.
- Handle late events, hot keys, and replay without double counting.
At scale
- For this exercise, assume five million hits per second and one billion distinct keys per day.
- Serve top-100 queries within 500 ms p99 and refresh results every five seconds.
- Support windows from one minute through 30 days.