Practice

Top K Heavy Hitter

For a platform like Spotify, design a sytem that returns the top K songs played in the last 7 days. The same solution can also be applied to getting the top K most popular items of an e-commerce platform.

Functional requirement:

  • When a user plays a song, increment count for that song
  • Return the top K songs played for the last 7 days

Scale requirement:

How many users are there?

  • 100,000,000 DAU

How many times does a user interact with content (listens to a song)?

  • 100 times a day.

How many times does a user request top k?

  • 2 times a day for last 7 days

How long should the raw data be retained?

  • Data retention for 1 year.
Step1
Step2
Step3
Step4
1. Resource Estimation