Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Stream & Batch Processing
DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC

Windowing, Watermarks & Backpressure

Aggregate endless event streams accurately even when events arrive out of order.

AdvancedPart of Stream & Batch Processing
Practice in AI HLD
Subtopics in Stream & Batch Processing (2)
OverviewWindows & WatermarksLambda vs. Kappa

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
Parent topic
Stream & Batch Processing
Next subtopic
Lambda vs. Kappa Architecture