How it works · 21 of 38 Core
Batch vs stream processing: what is the difference?
All at once, or as it happens
Batch vs streaming: Batch processing collects events and handles them together on a schedule (every night, every hour); streaming handles each event as it arrives, so answers come in seconds, but because events arrive late and out of order, a streaming total must wait a set margin (a watermark) before it is final.
Loading the animation…
Say it like this Batch processing collects events and handles them together on a schedule; streaming handles each event as it arrives, so it answers in seconds, but it must decide how long to wait for late events before calling a total final.
Under the hood — for builders
- Worked example: the scene's stolen card
- Swiped every four minutes. A midnight batch check sees it after 14 swipes; streaming declines the second:
- Event time vs arrival time
- Event time: when it happened. Processing time: when it reached you. The metro payment crossed 11:00 in transit:
- Watermark
- Flink's marker that event time has reached t, so windows ending before t can close. Later arrivals are "late".
- Real limits (Amazon Kinesis)
- Per shard: write 1 MB/s or 1,000 records/s, read 2 MB/s. Data kept 24 h to 365 days.
- Why retention matters
- A stream is also a replay buffer: a job that broke overnight can re-read the day it missed.
- Choose per question
- Seconds matter (fraud, alerts): stream. Must be exact (statements, tax): batch after the day closes.
- Watch out
- Streams redeliver after failures: make handlers safe to run twice, as in Queues & events.
- Sources
- Apache Flink docs, "Timely Stream Processing" · Amazon Kinesis Data Streams, "Quotas and limits" (read November 2026).
What happens in the batch vs streaming animation, step by step?
- A thief swipes a stolen debit card at a shop. Each swipe is an event: a small record of which card paid how much, where and when, sent to the bank at once.
- Batch processing collects events and handles them together on a schedule. This bank's fraud check reads the day's tray at midnight. It finds the thief, 14 swipes and ₹96,388 too late.
- Your turn: drag how often the fraud check runs. Streaming checks each swipe the moment it arrives, so the second swipe, 9 km from the first in four minutes, is declined.
- Streams have a catch: events arrive late and out of order. A payment made at 10:58 inside a metro station has no signal; it reaches the bank at 11:06, after the 10-to-11 total was sent.
- So stream processors count by event time, when it happened, not when it arrived, and wait a set margin before closing each hour. Apache Flink calls that marker a watermark. Wait 10 minutes and the late payment lands in its hour, but every total comes 10 minutes later.
- Most banks run both: streaming for fraud alerts in seconds, a nightly batch for statements that must be exact. Both end up as files with dozens of columns, and a report needs two. Must it read them all? Next: columnar formats.
What everyday example explains batch vs streaming?
The post office and the phone call. Letters pile up in the box and are sorted once a day, all together and in order (batch). A call is answered the moment it rings (streaming), but a caller with a bad signal gets through late, and you must decide how long to keep the line open before you hang up and write the day's notes.
Why should a team care about batch vs streaming?
For each report or alert, decide how fresh it must be and how exact: stream it when a minute's delay costs money (fraud, alerts), batch it when the answer must be complete (statements, billing), and when you stream, set the watermark per question and plan what happens to events later still.