Interview questions
What changes when the input never ends
1What changes when you move from batch to stream processing?
The input has no end, so total volume stops mattering. State must outlive any one process, so the engine grows a storage engine inside itself. And planning ahead is replaced by regulating with feedback.
Read moreStreaming removes the end
2How do you size a streaming job?
Not by total volume. Find each operator's rule for what it must remember. State bounded by keys is active keys × bytes per key; state bounded by time is rate × time held × bytes per record.
Read moreThe state-size arithmetic
3What does 'stateless' really mean for a streaming operator?
That the engine manages no state for it. It does not mean free of side effects: a call to a remote service is stateless as far as the scheduler knows, but gives different results when replayed.
Read moreStateless operators
State
4One key carries 30% of the traffic. Does adding parallelism help?
No. A key's state cannot be split, so throughput is capped at about 1 / 0.3 ≈ 3.3 times one instance (Amdahl's Law). Salt the key and aggregate in two phases, which works only for associative, commutative aggregates.
Read moreThe indivisible key
5What are the options for storing a streaming job's state, and what does each cost?
- On the JVM heap: garbage-collection cost grows with live state.
- Off heap: serialization on every access.
- An embedded LSM store on local disk: write amplification and compaction debt.
- Remote storage: a round trip per access, and keeping caches coherent.
Read moreState backends
6Why is a time-to-live on state dangerous?
It silently changes results: evicted state produces missing rows, not errors, and no one can tell "no match ever existed" from "the match was evicted".
Read moreTTL is a silent correctness change
Windows, timers and watermarks
7How do you make a 24-hour window that slides every minute cheap to compute?
Split it into panes: keep a partial aggregate per 1-minute pane, and combine panes when emitting. Each record is then added once instead of to 1,440 overlapping windows. It needs a mergeable aggregate; for distinct counts and quantiles, use sketches.
Read moreSliding windows
8Why can session windows exhaust memory?
A session ends only after a gap in activity, so a key that never goes quiet never closes its session. Declare a maximum session length.
9Why do timers matter for state size and latency?
Timers are keyed state themselves, often larger than the data they guard. And when the watermark jumps forward, every timer that is due fires at once, causing a burst of output.
Read moreTimers are stored state
10One Kafka partition is empty overnight, and windows stop closing. Why?
An operator's watermark is the minimum across all its input channels, so an idle channel holds it back. Mark idle channels so they are left out of the minimum.
Read moreWatermark propagationIdle channels
Joins and enrichment
11Why is a join between two streams always an interval join?
To discard a buffered record, you must prove no future record can match it, and that proof needs a time bound: one written in the query, or implied by the watermark plus the expected lateness.
Read moreStream-stream joins
12Why is enriching each record with a REST call slow, and how do you fix it?
Throughput is concurrency ÷ round-trip time (Little's Law): with a 5 ms round trip and one request in flight, 200 records per second per task. Use asynchronous I/O to keep many requests in flight, but expect non-deterministic results and a choice about output order.
Read moreStream-table joins and async I/O
13What is a temporal join, and why is it needed?
It joins each fact with the version of a dimension that was valid at the fact's event time. Joining with whatever is current gives different results on replay.
Changelogs
14Why is the output of a streaming aggregation a changelog, and what does that require downstream?
Aggregates over incomplete input must be revisable as more data arrives. So downstream operators must handle retractions (their aggregates must be invertible or recomputable), and sinks must upsert and delete by key.
Read moreChangelogs and table-stream duality
15Why is a retractable MAX expensive?
To "un-max" when the current maximum is retracted, you must keep every contributing value, so state grows with the window's contents instead of being a single number.
Read moreThree consequences
16Why is querying a streaming job's internal state directly usually a bad idea in production?
Reads see state that is not yet committed; serving load slows the pipeline through backpressure; addresses change when the job rescales; and the state is unavailable during recovery.
Read moreQueryable state
Checkpoints and exactly-once
17How does a streaming checkpoint work?
A barrier flows through the job with the data. Each operator snapshots its state when the barrier arrives, and source offsets are saved in the same cut, so state and input position recover together.
Read moreCheckpointing: a consistent cut
18What is the difference between aligned and unaligned checkpoints?
An aligned checkpoint waits for the barrier on every input before snapshotting, which slows down under backpressure. An unaligned checkpoint snapshots immediately and stores the records still in flight, at the cost of checkpoint size and write bandwidth.
Read moreAligned barriersUnaligned barriers
19Why do incremental checkpoints need an LSM-style state store, and what do they cost?
Only immutable files can be reused from one checkpoint to the next. The price is reference counting, garbage collection of old files, and periodic consolidation.
Read moreIncremental checkpointing
20Is exactly-once delivery possible in stream processing?
No. What systems provide is an exactly-once effect: a consistent checkpoint, plus a transactional or idempotent sink, plus replay that is deterministic.
21What does exactly-once with a transactional sink cost in latency?
Output stays invisible until the checkpoint completes, so end-to-end latency is at least the checkpoint interval. And the sink's transaction timeout must exceed the checkpoint duration plus the worst recovery time.
Read moreThe consequences are sharp
Scaling and flow control
22Why can a streaming engine not simply route records by hash(key) mod parallelism?
Changing the parallelism would remap most keys, 80% going from 4 instances to 5, and with them their state. Key groups add a fixed layer of indirection, so rescaling moves whole ranges of groups instead.
Read moreKey groups: the indirection
23What is backpressure, and how do you find the operator causing it?
Bounded buffers plus credit-based flow control slow the source down, hop by hop. The culprit is the first operator, reading downstream from the source, that is not itself being backpressured.
Read moreBackpressure propagationThree operational consequences
24Micro-batch or record-at-a-time processing: how do they really differ?
Both batch. They differ in where the batch boundary sits, whether it adapts, and whether it doubles as a transaction boundary. Latency alone no longer separates them.
Read moreMicro-batch versus record-at-a-time