Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Rolling Top-Users Event Leaderboard

Maintain the top one hundred users by event count over a continuously moving one-hour window.

Problem statement

For this exercise, assume that an analyst asks for the current top users while events arrive late, duplicate, and expire from the one-hour window. Accept user events with stable identity, event type, and event timestamp. Return the top 100 users by count in the trailing hour with a deterministic tie rule.

Incorporate bounded late events and expose the result watermark. Restore window state after worker failure without double-counting replayed events. Assume 500,000 events per second and 20 million active users in a busy hour. Refresh the leaderboard within five seconds and answer reads within 200 milliseconds at p95.

Accept events up to two minutes late, deduplicate for two hours, and retain aggregate checkpoints for one day. Preserve this invariant: each accepted event contributes at most once and expires exactly once from the event-time window.

Keep unrelated product features and company-specific infrastructure outside the first version.

What to build

  1. Accept user events with stable identity, event type, and event timestamp.
  2. Return the top 100 users by count in the trailing hour with a deterministic tie rule.
  3. Incorporate bounded late events and expose the result watermark.
  4. Restore window state after worker failure without double-counting replayed events.

At scale

  • For this exercise, assume 500,000 events per second and 20 million active users in a busy hour.
  • For this exercise, refresh the leaderboard within five seconds and answer reads within 200 milliseconds at p95.
  • For this exercise, accept events up to two minutes late, deduplicate for two hours, and retain aggregate checkpoints for one day.