Batch vs stream processing, and windows
Events become answers in two ways. Batch processing collects them and runs a job over a complete, bounded set, such as yesterday's. Stream processing updates the answers continuously as events arrive. Streams bring two new problems: grouping an endless flow into windows, and deciding when a window is complete when some events arrive late. Interviewers probe the second.
The market stall's takings
A market stall owner can count the cash box after closing: slow, but every sale is in it, and if she miscounts she counts again. Or she can keep a tally for each hour as customers pay, so by 10:01 she knows how the nine o'clock hour went. Some card payments clear minutes later, stamped with the time the customer paid. So she waits five minutes past each hour before writing that hour's total, and if a straggler turns up after that, she corrects the total or leaves it for the evening count.
- counting after closing → batch processing
- the running tally → stream processing
- each hour → a window
- when the customer paid vs when the payment cleared → event time vs processing time
- waiting five minutes → a watermark, with allowed lateness after it
- the evening count fixing the tallies → a batch job correcting stream results