LOAD-BEARINGfree
High-level designTier 7 · unit 3 of 7 · 13 min read

Batch or stream, and when nightly is correct

There is an assumption worth dismantling before anything else: that streaming is the grown-up version of batch, and a nightly job is what you run until you get round to doing it properly.

It is not a ladder. They are two designs with different failure modes, and one of them is dramatically easier to operate. The question is never "which is more modern" — it is what does it cost you for this answer to be a few hours old? For a large fraction of real pipelines the honest answer is "nothing", and the nightly job is not a compromise. It is correct.

What batch quietly gives you

Properties that are easy to overlook because they are absent rather than present:

  • It is re-runnable. Write output partitioned by day, and re-running yesterday overwrites yesterday. A bad deploy is fixed by running it again — Tier 6's idempotence, obtained by construction rather than by discipline.
  • It has a completeness boundary. "All of the 26th" is a set that is finished. Nothing needs to decide whether more data is coming, because the day is over.
  • You still have the input. When the number is wrong, the file that produced it is on disk. You can run the job again with a debugger attached — against a stream, the moment has passed.
  • Failure is bounded. A job that dies at 3am is a job that did not run. A streaming job that dies at 3am is a backlog that grows until someone wakes up.

What streaming costs, honestly

You buy freshness. You pay in correctness problems that batch simply does not have, and every one of them is a design decision you now own.

Event time is not processing time. This is the whole subject in one line. A phone loses signal at 6am and reconnects at 9am, and three hours of events arrive at once. Two clocks:

  • Processing time — when your system saw the event. Always available, trivially ordered, and produces answers that are wrong.
  • Event time — when the thing actually happened. What every business question means, and it arrives out of order.

Bucket those 9am arrivals by processing time and Tuesday's 6am revenue lands in Tuesday's 9am bucket. The chart looks fine. It is simply not true.

Which forces windows and watermarks. To aggregate by event time you must decide when a window is finished — but you cannot know whether one more event is coming. A watermark is the system's assertion that it no longer expects events older than time T, and it is fundamentally a guess. Set it aggressively and you drop late data. Set it conservatively and every result is delayed by the allowance. There is no setting that is both, so you also need a late-data policy: drop it, send it to a side channel, or emit a correction that downstream consumers must be built to accept.

And state must survive. "Count per user per hour" means the job holds state, potentially for millions of keys, in a process that must never lose it. Stream processors solve this with checkpointing, which is real engineering you are now operating: checkpoint intervals, state backends, recovery time, and a state store that can outgrow memory.

One clarification worth carrying, because the marketing is misleading: when a stream processor claims exactly-once, it means exactly-once effect on its own managed state, via checkpoints and transactional sinks. Tier 6's conclusion has not been repealed — end to end, across a boundary the processor does not control, it is still at-least-once plus idempotent consumers.

Choosing, in one question

Ask what a decision made on N-hour-old data costs.

  • Nothing → batch. Monthly billing, financial reporting, model training sets, most dashboards. Nobody acts on the 3am number at 3am. Streaming here buys an operational burden and no decision changes.
  • A lot → stream. Fraud scoring, live inventory in a booking flow, alerting, anything a user sees change. The freshness is the product.
  • Somewhere between → micro-batch, and this is the underrated answer. Run the batch job every five minutes. You keep re-runnability, completeness boundaries and debuggability, and you go from twenty-four-hour staleness to five-minute staleness. Most "we need streaming" requirements are satisfied here, at a small fraction of the complexity.

You will also meet the two named architectures. Lambda runs a streaming path for fresh approximate answers and a batch path that recomputes the truth, with the batch result winning. Kappa says one streaming path is enough, and replays the log when you need to recompute. The pragmatic reading: Lambda's cost is maintaining the same business logic twice and watching the two copies drift; Kappa's cost is that replaying a large log to fix a bug is a slow, high-stakes operation. Most mature systems land on a stream for freshness plus a scheduled batch job that reconciles it — which is Lambda, chosen reluctantly, and it works.

The trap

Building a streaming pipeline for a dashboard nobody opens before 9am. You have taken on watermarks, late data, checkpointed state and a job that fails at 4am into a pager — to make a number fresh at an hour when the only thing awake is the pipeline. Freshness is a requirement someone must ask for and be able to justify, not a default. "It would be nice if it were live" is not a justification; it is how a team acquires an on-call rotation for a bar chart.