SevyDevy

Design a top-k heavy hitters system

PremiumData pipelineMedium

  • Top k
  • Heavy hitters
  • Count min sketch

Quick answer

This data pipeline interview question asks you to design a top-k heavy hitters system. Aim for a design that moves data from sources to consumers reliably and on time, then explain ingestion, processing, storage and trade-offs. Interviewers want to see how you handle volume, late or bad data and failures along the way.

The problem

Design a top-K heavy hitters system for a video platform: it returns the 100 most-watched videos per country and worldwide over the last hour, day and week, from 5 billion plays a day. The hard parts are counting millions of keys cheaply, sliding windows and fresh lists without scanning everything.

The lists power a Most Watched page and are also used to warm caches. They rank by raw play counts; trend detection and personalisation are separate systems.

What must a top-k heavy hitters system do?

  • Top lists: Return the top 100 videos by plays for each country and worldwide.
  • Windows: Support the last 1 hour, last 24 hours and last 7 days, each sliding rather than reset at midnight.
3 more requirementsUnlock to see all

How well must it do it?

  • Freshness: The 1-hour list updates every minute, the 24-hour list every 5 minutes and the 7-day list every hour.
  • Accuracy: The 1-hour list may be approximate within a stated error; the 7-day list must match an exact count.
2 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • Top k
  • Heavy hitters
  • Count min sketch
  • Sliding windows
  • Stream processing
  • Hot keys

How you’ll practise

6 short steps · save and come back any time
  1. Requirements
  2. Data volume
  3. Ingestion
  4. Storage and processing
  5. Serving and freshness
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any data pipeline design round.

  • Clarifies sources, consumers and freshness needs
  • Chooses batch, streaming or both with reasons
  • Handles late, duplicate and malformed records
  • Makes each stage safe to retry
  • Explains storage formats and partitioning
  • Plans monitoring, backfills and data quality checks

Questions people ask about this interview question

Which design type is this question?
It is a data pipeline question. You design a top-k heavy hitters system and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
What should I cover first?
Start with the data sources, the consumers and how fresh the data must be. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it