Coding Interviews: System Design
Collapse
AllHardEasyMediumVideoPythonCode SolutionJavaJavascript
A video service (like youtube) has many viewers watching videos. Given a stream of the video IDs that are being watched, we need to find the top K most viewed videos for different periods of time (1 hour, 1 day, 1 month, all time). For the top K videos returned, we also want the count of views during this period.
Design a distributed Least Recently Used (LRU) cache. The distributed aspect of the cache is the key requirement, with high availability and scalability as the core non functional requirements. The cache itself only need simple get and set operations but it should follow the LRU strategy for evicting data.