Overview of Stream Processing 00:00:01 Count a live crowd through a moving gate A festival operator wants a rolling count while people are still arriving. The event stream has no final row. The job incrementally updates bounded pieces of state, emits answers, and keeps listening. A click, a page view and a purchase are appended to the topic. The job has not read them yet. The click and the page view belong to window 1. The purchase carries a later time and belongs to window 2. The watermark passes the end of window 1, so its count is final for now. Read, group, close, send: all day and all night. Give each answer an explicit time window and revision rule. A count that will change when late readings arrive is a different promise from the official settled total. 00:00:50 A delayed wristband knows when it was scanned A disconnected gate uploads a scan after a later scan has already arrived. Event time says when it happened. Processing time says when the job saw it. A watermark estimates how far event time has advanced. The newest scan is one second past ten. With five seconds of delay, the watermark sits four seconds before ten. The first window remains open. A scan seven seconds past ten enters the next window. The watermark is two seconds past ten, still before the first window closes at five seconds past ten. A scan from two seconds past ten arrives after the one from seven seconds past ten. Its window is still open, so count it. Later a scan from four seconds past ten arrives after its window has been removed. Send it to the side output for reconciliation. This example routes an event that misses the configured window to a side output. Other designs can accept allowed lateness and revise a prior count. The choice affects both correctness and memory. 00:01:59 Three questions need three windows How many arrived each five minutes, how many in the most recent ten minutes, and which scans belong to a visit? Draw the windows on the same event line and follow just one wristband. Fixed size, no overlap. Each event is in exactly one window. Fixed size that overlaps: size 10 and hop 5 put each event into 10 / 5 equals 2 windows. Flink calls these sliding windows. A session grows while the gap is under 4 seconds. From 6 to 12 is 6 seconds, so a new one starts. Per five minutes: tumbling. Rolling average: hopping. One visit of one person: session. With overlapping windows that event can influence multiple results. A session window groups activity by gaps, so events near the boundary can change the grouping if the lateness policy permits. 00:02:55 Recover the count and its bookmark together One worker crashes after processing two events beyond its checkpoint. If the stored count and source position belonged to different moments, recovery could miss or double-count entries. After event 3 the job stores the offset and its counts together. Events 4 and 5 were counted in memory. Then the machine dies and the memory is gone. Events 4 and 5 are read again from the log. The log must still have them. The result overwrites the same row, so the dashboard is still right. An insert would have doubled it. Commit source position and state consistently, keep input through the recovery window, and choose an output write that safely replaces or commits the right result when the job replays. 00:03:39 The scoreboard slows to four hundred writes per second A slow result store can turn into growing consumer lag. With a thousand arriving and four hundred leaving each second, the missing six hundred do not disappear while the source retains them. 1,000 events a second in, 1,000 out. It accepts only 400 a second. The job's buffers fill up. The job reads less. 600 events a second stay in the topic, so 10 minutes leave 360,000 behind. Nothing is lost. The database is back and takes 2,000 a second. The spare 1,000 clear the lag in 360 seconds. Compare input rate, processing rate and oldest unprocessed event age. To clear a backlog while arrivals continue, spare throughput is completion rate minus arrival rate. The slower sink sets the real pace.