Code Room
System designHardsd-g191
Subject Batch vs streamLevel Senior–Staff~45 minCommon in Distributed systems interviewsIndustries Technology, Software development

Question

Design real-time sessionization for a video-streaming product: group a user's events (play, pause, seek, buffer, ad-view) into 'viewing sessions' (gap of >30 min of inactivity ends a session), computing per-session metrics (watch time, rebuffer ratio, ads served) within ~1 minute of session end to feed live experiment dashboards and an anomaly detector. ~2M concurrent viewers, events arrive out of order and occasionally minutes late (mobile networks). Decide between a streaming and a batch approach and design the windowing and state.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.