← All parts

End-to-End Design

Design Top K (Trending) · Part 3
Problem context

Design a system that surfaces the top K items from a continuous stream of events — the most-played songs, the most-viewed videos, the most-frequent search queries — over rolling time windows like the last hour, the last day, or the last 7 days.

In scope: ingesting play or view events at high volume, maintaining the top K items over those windows, and answering a top-K query in milliseconds. Out of scope: personalizing the ranking per user, filtering spam or bot traffic, and reporting an exact per-item count for billing. Those are separate systems that read the same event stream.

Heavy hitter. In a stream of events, a heavy hitter is an item that appears far more often than the rest — the handful of viral videos among billions of uploads. Finding the top K is the problem of finding the heaviest hitters.

What a strong answer sounds like

State the decision, connect it to a requirement, and name the tradeoff. Keep the design focused on the workload in the prompt.

Ready for the end-to-end design interview?

The AI interviewer asks about this part of Design Top K (Trending). The interviewer guides you through topics one by one.