Stream Processing Architectures • Windowing & Time-based AggregationsEasy⏱️ ~2 min
What is Windowing in Stream Processing?
Definition
Windowing is a technique that creates temporal boundaries on an infinite stream of events so you can compute meaningful aggregations like "transactions per user in the last 5 minutes" or "average latency per service in the past hour."
💡 Key Takeaways
✓Windowing creates finite temporal boundaries on infinite event streams, enabling aggregations like counts, sums, and averages over defined periods
✓Tumbling windows are non overlapping fixed intervals where each event belongs to exactly one window, offering simplicity and low memory overhead
✓Sliding windows overlap by having a step size smaller than window size, allowing each event to belong to multiple windows for smoother trend detection
✓Session windows are per key dynamic windows that close after inactivity, perfect for analyzing user behavior patterns and engagement sessions
📌 Interview Tips
1A fraud detection system uses 5 minute sliding windows (sliding every 1 minute) to track transaction count per card, catching spikes that indicate possible fraud
2Netflix computes error rates per region using 1 to 5 minute tumbling windows, triggering alerts when quality metrics degrade beyond thresholds
3An e-commerce site uses 30 minute session windows per user to analyze shopping patterns, where a session closes after 30 minutes of inactivity