Batch vs. Stream Processing 00:00:01 One ledger, two clocks A market treasurer needs an official daily report. The safety desk needs to spot suspicious payments while the market is open. Both read the same events, but their deadlines are entirely different. The folder collects them. The stream job handles them and writes result 1. Batch waits. Stream writes result 2. At 02:00 the batch job wakes up and reads all nine at once. One complete report. The stream's readers saw numbers hours before, in three pieces. Use the nine payments to compare the answers people can see along the way. By the end, both approaches can compute the same total if they use the same event set and definition. 00:00:44 Share the cost of opening the ledger Suppose the fixed commit takes two milliseconds and the actual arithmetic across all records takes ten. Batching lets many payments share that fixed cost. The earliest payment may wait while the batch fills. 1,000 commits of 2 ms each, plus 10 ms of work. 100 commits. 10 commits. The fixed cost is shared by many payments. One commit: 12 ms. The first payment waited for the last one to arrive. Measure two clocks separately. System throughput describes how much work finishes. User-visible freshness includes the wait to fill the batch, process it and publish the result. 00:01:26 The accountant uncovers a three-week mistake Both implementations used the wrong fee for twenty-one days. The batch warehouse has complete source files. The live topic retains seven days. Correct code alone cannot recover the missing two weeks. Every daily report of the last 21 days is too high. The raw files are complete. Run the fixed job for each day. It replaces that day, so running it twice does no harm. A second job reads the topic from the start into a new table. The topic holds 7 days. 21 minus 7 days are gone from the topic. They have to come from the raw files. Rebuild into a separate output and validate daily totals before switching readers. Retain enough authoritative input for the correction horizon your business actually promises. 00:02:15 Give each consumer the freshness it needs Slot four jobs onto the timeline. A decision needed during checkout has a different latency budget from a monthly statement. A dashboard tolerated five minutes of staleness in the example. The payment waits for the answer. Only a stream, or a direct check, is quick enough. Nobody reads it before the month is over, and it must be complete. Five minutes are fine. A small batch every few minutes is simple. Keep one log. A stream feeds the screen and a batch job makes the official number. A small periodic batch may satisfy a dashboard with less operational state. A low-latency stream can share the same immutable input with a slower, reconciled report. 00:02:58 Leave room for the failed run A nightly job looks safe when its normal completion is before breakfast. Let volume grow and inject one failure near the end. The deadline now depends on rerun time as well as normal runtime. The job starts at 02:00 and takes 1 hour. The report is ready at 03:00. Five times the data on the same machines: 5 hours. Still ready at 07:00. It fails at 06:30 and starts again: 06:30 plus 5 hours is 11:30. The morning meeting has no numbers. Run every hour on one hour of data, about 21 GB. A failure costs minutes, and the last step is short. Choose batch size, checkpoints and spare processing capacity against the recovery deadline. The right design is the one that delivers the required answer with the necessary freshness and correction history.