DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC
Windowing, Watermarks & Backpressure
Aggregate endless event streams accurately even when events arrive out of order.
AdvancedPart of Stream & Batch Processing
Subtopics in Stream & Batch Processing (2)
In plain words
Because a stream never ends, you slice it into time buckets ("every 1 minute") and wait a tiny grace period (watermark) for straggler events stuck on slow mobile networks before closing the bucket.
Think of it like…
Tallying marathon runners in 5-minute finish brackets while waiting 30 seconds for a delayed timing chip to sync.
Loading interactive diagram
Loading interactive exercise
Theory & how it works
Handling Backpressure
If events arrive faster than your stream processors can write to the database, buffers fill and crash with OOM. Backpressure signals upstream readers to slow down pulling from Kafka (since Kafka safely holds events on disk!) until downstream catches up.
Key points & practical guide
Summary checklist
- Tumbling windows don’t overlap; Sliding windows overlap; Session windows group by activity gaps
- Watermarks balance completeness vs. result latency
- Kafka absorbs backpressure safely on disk
When to use it
- Real-time fraud rules, live leaderboards, surge pricing, anomaly alerts
Watch out for
- Confusing Processing Time with Event Time - breaks accuracy during mobile outages or replays
Quick check
Loading quiz