Batch & Streaming · Core Concepts

Stateful vs stateless processing

Easystatefulstatelesswindowscheckpoint

Interview question

What is the difference between stateful and stateless stream processing?

How to answer

The short answer

Stateless processing looks only at the current event. Map, filter, and simple projections are usually stateless. Restart is easy: no memory of the past to restore.

Stateful processing remembers something across events: running counts, last seen value, session windows, joins between streams. That memory is state, often keyed by user_id / order_id.

Output
Stateless:  event -> filter(amount > 100) -> sink
            (no memory)

Stateful:   event -> update count[user] += 1 -> emit if count > 5
            needs keyed state store + checkpointing

Tiny example

  • Stateless: tag each click with is_mobile
  • Stateful: count clicks per user in the last 5 minutes (needs window + state)

Why it matters

State must be checkpointed for recovery. Skewed keys blow up memory. Exactly-once sinks care about state + offsets together.

Interview tip: If the answer depends on "what happened before," it is stateful. Then mention keys, checkpoints, and TTL.