ScaleCrafts

Design trending topics (top K)

HardStreamingApproximationTop K

Find the top trending hashtags or videos over the last minute, hour and day from a firehose of events, like Twitter Trends.

Functional requirements

  • Top K items for the last 1 minute, 1 hour and 24 hours
  • Trends per country
  • Results refresh every minute

Non-functional requirements

  • Handles a huge event stream
  • Results fresh within a minute
  • Approximate counts are acceptable

Scale

  • 1M events per second
  • Hundreds of millions of distinct items
  • K up to 100

How you’ll be scored

9 checks covering your diagram and your notes, and any valid approach counts. Hints appear for anything you miss. Common mistakes, such as single points of failure or components you never explain, cost points. How grading works

What interviewers look for

  • Clarify before you draw. State what is in and out of scope. For “Design trending topics (top K)”, that starts with: Top K items for the last 1 minute, 1 hour and 24 hours; Trends per country; Results refresh every minute. Interviewers notice candidates who pin the requirements down first.
  • Turn the scale into numbers. The scale (1M events per second; Hundreds of millions of distinct items; K up to 100) should become requests per second, storage and bandwidth, and those figures should drive your choices. Estimates with units carry more weight than adjectives.
  • Show how each quality is met. Your design should visibly deliver: Handles a huge event stream; Results fresh within a minute; Approximate counts are acceptable. Saying that it does isn’t enough; point to the part of the design that makes it true.
  • Expect follow-ups on the hard parts. Interviewers usually probe streaming, approximation and top k here. This is a hard problem, so interviewers expect depth: what breaks first at this scale, how each failure is contained, and which trade-offs you accepted on purpose.
  • Explain failure and trade-offs. Say what happens when a component fails, where a single point of failure would hurt, and what you chose not to build. Naming a trade-off is a stronger answer than claiming there isn’t one.

Related problems

Loading your workspace…