Practice/Meta/Design Typing Indicator
Product DesignOptional
Design a system that displays real-time viewer counts for live video streams, similar to what you see on YouTube Live, Twitch, or Instagram Live. When users join or leave a live stream, the viewer count should update for all participants within seconds. The system needs to handle popular streams with millions of concurrent viewers while maintaining accurate counts and efficient resource usage.
Your solution should account for the challenges of tracking ephemeral connections, dealing with network instability, preventing count manipulation, and efficiently broadcasting updates to massive audiences without overwhelming backend services or client devices.
Based on real interview experiences, these are the areas interviewers probe most deeply:
Understanding how to efficiently track millions of ephemeral connections without overloading your system is fundamental. Interviewers want to see how you handle the difference between "watching" and "connected" states, especially when users pause streams, switch tabs, or experience network hiccups.
Hints to consider:
With millions of viewers, you cannot simply broadcast every join/leave event to everyone. Interviewers look for sophisticated aggregation strategies that balance accuracy with system load.
Hints to consider:
Real-world systems face browser crashes, mobile app backgrounding, network partitions, and malicious actors. Strong candidates proactively address these scenarios.
Hints to consider:
The choice of database and how you model viewer sessions significantly impacts system performance and accuracy.
Hints to consider:
Start by confirming the scale and expectations. Ask about the maximum concurrent viewers for the most popular streams, whether exact counts are required or approximations are acceptable, and what latency is tolerable for count updates. Clarify if you need to support anonymous viewers versus only authenticated users, and whether you need to detect unique viewers or just concurrent connections. Confirm requirements around bot detection, historical analytics storage, and whether different viewer types (mobile vs web) should be tracked separately.