1.Batch vs stream processing
Batch processing runs a job over a bounded, already-collected set of data — yesterday's orders, a full table export — on a schedule or on demand, then finishes. Stream processing runs continuously over an unbounded sequence of events as they arrive, one at a time or in small groups, and never "finishes" in the same sense. The choice is about how fresh the result needs to be versus how much complexity you are willing to run permanently.
Key features
- Batch input is bounded and known in advance (a file, a table snapshot, a fixed date range) — the job has a defined start and end.
- Stream input is unbounded — the job starts once and keeps running, processing events as they arrive with no defined end.
- Batch jobs are simpler to reason about and retry: rerunning the same bounded input produces the same result (idempotent by construction, if the job itself is deterministic).
- Stream jobs trade that simplicity for freshness — results reflect events within seconds, not the hours or days a batch schedule implies.
- Many production systems run both: a stream path for low-latency approximate results, and a nightly batch job that recomputes the exact answer over the full bounded dataset (the "lambda architecture" pattern).
Batch vs stream processing — the decision-relevant differences
- Batch
- Input is a fixed file or table snapshot
- Job starts, processes everything, exits
- Rerunning the same input reproduces the same result
- Stream
- Input is an unbounded sequence of events
- Job starts once and keeps running indefinitely
- Recovery resumes from a checkpoint, not a full rerun
Command
// Batch: bounded input, runs once, exits
job.read(source="orders_2026_08_24.parquet")
.aggregate(by="customer_id")
.write(sink="daily_totals")
// process exits when the file is fully read
// Stream: unbounded input, runs forever
stream.read(source="orders-topic")
.aggregate(by="customer_id", window="1h")
.write(sink="running_totals")
// process keeps running as new events arriveBatch processes a bounded, already-collected dataset on a schedule and then exits; stream processes an unbounded sequence of events continuously and never exits. Choose based on whether the result needs to be current within seconds (stream) or can wait for the next scheduled run (batch) — not based on which sounds more modern.