Design a Rolling Shared-Article Leaderboard
Maintain top-N shared articles across five-minute, one-hour, and twenty-four-hour rolling windows.
Problem statement
For this exercise, assume that a publisher records a share and readers see fresh ranked articles for each supported rolling window. Accept an idempotent article-share event with event time. Return top-N articles for rolling five-minute, one-hour, and twenty-four-hour windows.
Apply a bounded late-event policy and expose result watermarks. Recover window counts and rankings from durable events and checkpoints. Assume one million share events per second and 100 million distinct active articles per day. Refresh five-minute rankings within two seconds and longer windows within ten seconds.
Accept events up to one minute late and retain deduplication identities for twenty-five hours. Preserve this invariant: one share contributes at most once to every applicable window and expires from each window at its correct event-time boundary.
Keep unrelated product features and company-specific infrastructure outside the first version.
What to build
- Accept an idempotent article-share event with event time.
- Return top-N articles for rolling five-minute, one-hour, and twenty-four-hour windows.
- Apply a bounded late-event policy and expose result watermarks.
- Recover window counts and rankings from durable events and checkpoints.
At scale
- For this exercise, assume one million share events per second and 100 million distinct active articles per day.
- For this exercise, refresh five-minute rankings within two seconds and longer windows within ten seconds.
- For this exercise, accept events up to one minute late and retain deduplication identities for twenty-five hours.