KatInterview

Design a Scalable Video Like-Count Engine for Viral Bursts

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemscaching

Last updated

Architect a high-performance system to handle user video likes, user engagement tracking, and extreme traffic bursts on viral content.

Design the backend services and storage infrastructure for the "like" reaction feature on a global video platform.

Functional Requirements

  1. Toggle Like State: Logged-in users can add or remove a like on a video.
  2. Retrieve Total Likes: Any viewer (authenticated or anonymous) can view the current count of likes on a video page.
  3. Retrieve Viewer State: Logged-in users can view whether they have currently liked the video being watched.
  4. User Activity Ledger: Logged-in users can request a paginated history of all videos they have liked.

Non-Functional Requirements & Constraints

  • High Throughput & Low Latency: The system must handle hundreds of thousands of read requests per second globally, with video page counter lookups returning in under 30 ms.
  • Viral Traffic Spikes: Popular video releases or breaking events can trigger sudden localized bursts of up to 100,000 like updates per second on a single video entity.
  • Strict Deduplication & Idempotency: Each user may contribute at most 1 like to a video's aggregate count. Network retries or duplicate UI interactions must not corrupt the total count.
  • Read-Your-Own-Writes for User State: A user who likes a video must immediately see the liked state reflected on their interface upon page reload or navigation, even if the public counter updates asynchronously.

Detail your data storage schemas, read/write pipeline architectures, hot-key mitigation strategies, counter accuracy guarantees, and key system trade-offs.

Hints

Hint 1

Decouple the transactional state of user actions (user X liked video Y) from the aggregate counter calculation engine (total likes for video Y).

Hint 2

To solve single-key bottlenecks during viral bursts, combine write-ahead buffering with sharded counters or windowed aggregation queues.

Hint 3

Use read-your-own-writes consistency (or optimistic UI updates with user-level cache) for the active user's state, while allowing global aggregate counters to remain eventually consistent by a few seconds.