System Design ยท medium

Batch vs streaming: how do you decide for a given use case?

Asked in Data Engineer interviews, in the System Design round.

Short answer

Latency needs, cost, complexity, data freshness SLAs, and correctness guarantees.

BatchStreaming
FreshnessMinutes to a daySeconds
Cost per eventLowHigher, always-on infrastructure
Reprocessing historyRerun the jobReplay the log, harder
Late dataThe next run picks it upNeeds watermarks and windows
Operational loadA failed run is a rerunOn-call for an always-running consumer
Choose it whenA dashboard or a daily modelFraud, alerting, live personalisation
Ask what the decision latency actually needs to be, then take the cheaper option.

How to answer it

The decision

Start from the decision latency the business actually needs, not from the technology. The table above compares the two; what follows is how to choose between them without guessing.

The questions that decide it

Cost

Batch       compute in bursts, idle between runs, cheap
            one failure = one rerun

Streaming   always-on infrastructure, always-on cost
            a failure at 3am is an on-call page
            plus watermarks, windows and late-arrival handling

Streaming is not just more infrastructure; it is more concepts the team has to hold. That is the cost people underestimate.

The middle ground

Micro-batching every five or fifteen minutes covers a surprising share of "real-time" requests at batch-like cost and complexity. When someone asks for real time, ask what they will do with it: often a fifteen-minute refresh is indistinguishable to them and an order of magnitude cheaper.

Key points

FAQ

The 30-second answer

I would start from the decision rather than the technology: what action gets taken on this data, and how quickly does it have to happen. Blocking a fraudulent payment is seconds, so that is streaming. A weekly report is not, so that is batch.
Then I would ask what an hour of staleness actually costs. If the answer is nothing, batch, because it is cheaper, a failure is just a rerun, and reprocessing history is straightforward, which in streaming it really is not.
The option I would raise explicitly is micro-batching every ten or fifteen minutes, because when someone asks for real time that is very often indistinguishable to them and an order of magnitude cheaper. Streaming costs more than infrastructure: watermarks, windowing and late arrivals are concepts the whole team then carries.

In the interview

Practice this for real