How it works
A batch job reads bounded data, meaning an input with a known end, such as yesterday’s order files in S3. It computes a result and exits. If it fails or has a bug, you rerun it over the same files and replace the output. A stream processor reads unbounded data, an input that is still being written, such as card payments arriving now. It has no natural finish, so it must carry its running state across restarts and decide when a result is ready to emit.
Take one marketplace, with example numbers. Seller payouts run at 02:00 over 6 million completed orders and take 20 minutes. Sellers are paid once a day, so a fresher total changes nothing, and a bad run is repaired by rerunning it. The finance ledger report is similar: it must be complete, and a closed day gives a complete input. A stolen card is different. Five orders in two minutes must be stopped before they ship, and a nightly job could notice up to a day late. A live operations dashboard also suits a stream, provided its numbers are labeled provisional.
Streaming has real costs: compute that never stops, state that must survive crashes, events that arrive out of order, and harder reprocessing. A useful test is to ask what decision changes if this number arrives an hour sooner. If the answer is none, keep the nightly job. Many systems run both, with a stream serving early estimates and a batch job producing the number of record.
Finance needs a daily revenue report that matches the ledger to the cent. A product manager asks you to make it real time because the team already runs Kafka. Would you replace the nightly job?
Keep the nightly job as the number of record: it reads a closed, complete day and can be rerun after a bug. If someone will act on intraday revenue, add a stream-fed dashboard labeled provisional. Already having Kafka lowers the cost of a stream, but it does not make a moving total reconcile with a ledger.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Bounded input lets a job finish and rerun; unbounded input never gives it that moment.
- Streaming pays for freshness with always-on compute, durable state, and out-of-order data.
- Keep the nightly job when nobody acts differently on a fresher number.