IMEN891K / IDSC501 / AXGS-501 · Data Engineering · Fall 2026

13. Big Data III: Stream Processing

Sangwoo Mo · POSTECH
Industrial & Management Engineering

Where We Are

PART IPART IIPART IIICollection and PreparationLec 2-5SQLLec 6-8NoSQLLec 9-10Big DataLec 11-13Monitoring and UpdatesLec 14-17

Recap: A Result That Can Be Rebuilt

Source readingskeep the inputProcess againrepeat the chosen rangeResult tableavoid extra copies
Reading the same input again should preserve the intended result

Outline: Big Data III

01

Recording Events

why streams need a retained event log

02

Reading and Restarting

remember a position and handle repeated readings

03

Handling Late Arrivals

use the measurement time to update the right result

01 · Recording Events

01

Recording Events

why streams need a retained event log

02

Reading and Restarting

remember a position and handle repeated readings

03

Handling Late Arrivals

use the measurement time to update the right result

Batch and Stream ProcessingBatch processes a bounded set; streaming updates results as more events arrive

2025 batch and streaming processing comparison
The difference is how ongoing input becomes an updated result

The Same Readings, Different UpdatesThe same count can be computed after a batch or updated during a stream

Batch: wait, then process the setCollect E1–E3E4 arrivesProcess all fourcount = 4Stream: update as records arriveE1 → 1E2 → 2E3 → 3E4 → 4
Streaming makes a current result available before the input stops

Four Readings from One MachineEach row is one M1 reading; count readings at or above 80°C

ReadingMeasured atArrived atTemperature
E110:0110:0182°C
E210:0410:0486°C
E310:0610:0690°C
E410:0310:0784°C
E4 describes an earlier measurement that arrives last

A Current Value Loses the History

At 10:01M1 = 82°CAt 10:04M1 = 86°CCurrent value only82°C disappears
Overwriting one current value loses the earlier reading

One Event, One ReadingAn event records one occurrence with its own identity

FieldE1 valueMeaning
event_idE1This measurement
machine_idM1The machine
measured_at10:01When it happened
temperature82°CThe measured value
E1 identifies the reading; M1 identifies its machine

The First Record in a LogA log appends incoming events in order

Stored M1 readingsE1 / M110:01 / 82°Cposition 0
E1 occupies position 0 in the stored log

New Readings Append at the End

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2
E1 remains stored when E2 and E3 append

A Late Reading Still Appends Last

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2E4 / M110:03 / 84°Cposition 3
E4 receives position 3 even though it happened before E3

Producer, Log and ConsumerThe producer writes events; the consumer reads them

Producerwrites each readingStored logE1 E2 E3 E4Consumerreads and counts
Writing a reading and processing its result are separate steps

LinkedIn Needed Fresh Activity DataActivity logs became inputs to live services as well as later analysis

Website activitypage views and searchesMore than reportslive search and recommendationsOne event streamserve both uses
The same event data had to reach both live services and batch analysis

Kafka Begins at LinkedInKafka was open-sourced in 2011 to deliver activity records to online and offline systems

LinkedInKreps / Narkhede / Rao2011Kafka open source and paperCore ideaa shared retained log
A shared log connected the activity producers to different readers

Kafka Holds the Event Log

Sensor producersend M1 readingsKafka topicsensor-readingsCounting consumerupdate the result
The topic gives the event stream a name

Decoupling Writers and ReadersA retained log lets writers and readers work at different times

2025 producers writing to a shared log with independent downstream readers
A new reader can use the log without adding a new producer connection

Two Readers, Two PositionsIndependent readers can consume the same retained events at their own pace

The same retained log: E1 E2 E3 E4Live displayE1 E2 E3 / count 3Read next: 3Daily reportE1 / count 1Read next: 1
The display resumes at E4; the report resumes at E2

Partitions Split a Topic into LogsA partition is one ordered log inside a topic

Topic sensor-readings: two separate logsM1keyPartition 0E1position 0E2position 1E3position 2E4position 3M2keyPartition 1Other readingposition 0
M1 readings stay together in partition 0

A Key Keeps One Machine TogetherHere the record key is the machine ID

Topic sensor-readings: two separate logsM1keyPartition 0E1position 0E2position 1E3position 2E4position 3M2keyPartition 1Other readingposition 0
The fixed mapping sends every M1 reading to the same log

An Offset Names a PositionOffsets belong to one partition

PartitionOffsetStored reading
00E1 from M1
01E2 from M1
10A reading from M2
Offset 0 in two partitions identifies two different records

02 · Reading and Restarting

01

Recording Events

why streams need a retained event log

02

Reading and Restarting

remember a position and handle repeated readings

03

Handling Late Arrivals

use the measurement time to update the right result

Reading the First Record

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 1Saved restart position: 0Result rows: E1 / count 1
After processing E1, the next read position becomes 1

Reading the Second Record

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 2Saved restart position: 0Result rows: E1, E2 / count 2
Two processed readings produce two result rows

Saving the Restart PositionCommitting an offset saves where a reader should resume

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 2Saved restart position: 2Result rows: E1, E2 / count 2
Saved position 2 means E3 is the next record after restart

A Failure Before Saving the Position

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 3Saved restart position: 2Result rows: E1, E2, E3 / count 3
E3 reaches the result, but saved position remains 2

Restarting from the Saved Position

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 2Saved restart position: 2Result rows: E1, E2, E3 / count 3
The restarted reader returns to E3 at offset 2

The Same Reading Can Appear TwiceReplay means reading stored records again

Stored M1 readingsE1 / M110:01 / 82°Cposition 0E2 / M110:04 / 86°Cposition 1E3 / M110:06 / 90°Cposition 2Read next: 3Saved restart position: 2Result rows: E1, E2, E3, E3 / count 4
Three distinct readings can produce four rows after replay

Reading ID and Machine ID

Stored inputMachineEvent identity
First measurementM1E1
Second measurementM1E2
E3 replayM1E3 again
Different M1 events survive; a second copy of E3 does not

Keeping One Result Row per Event

Read E3 againsame event_idFind existing E3keep one rowCorrect countE1 E2 E3 = 3
A unique event ID keeps replay from adding a second row

Demo: Read, Save and RestartPredict the result after restart, then repeat with unique event IDs

Simulation: read E1 and E2, save position, read E3, restart, then read E3 again

Compare result rows before and after reading E3 a second time

Answer: Read, Save and Restart

ActionSaved positionResult rows
Read E1 and E2; save2E1 E2
Read E3; restart2E1 E2 E3
Read E3 again2E1 E2 E3 E3
Repeat with unique event IDs2E1 E2 E3
The saved position controls replay; event identity controls repeated result rows

Processing Before Saving Progress

Read E3offset 2Store resultone row for E3Save positionnext offset 3
Saving progress after the result leaves replay possible during a failure

Rebuilding a Result from the Log

Stored E1 E2 E3start again at 0Empty result tableprocess the recordsRebuilt resultE1 E2 E3 = 3
A retained log can rebuild a result from the same input

03 · Handling Late Arrivals

01

Recording Events

why streams need a retained event log

02

Reading and Restarting

remember a position and handle repeated readings

03

Handling Late Arrivals

use the measurement time to update the right result

One Reading Has Two TimesEvent time is when the measurement happened

Measured at10:0010:0510:10E1E2E3E4Arrived at10:0010:0510:10E1E2E3E4
E4 happened at 10:03 and arrived at 10:07

Counting by Measurement TimeCount hot readings in each five-minute measurement interval

10:00 to before 10:05E1, E2count 210:05 to before 10:10E3count 1
Before E4 arrives, the earlier interval contains E1 and E2

A Late Arrival Updates the Earlier Interval

10:00 to before 10:05E1, E2, E4count 310:05 to before 10:10E3count 1
E4 changes the earlier count from 2 to 3

The Clock Changes the Answer

Time used10:00 to before 10:0510:05 to before 10:10
Measurement timeE1 E2 E4: 3E3: 1
Arrival timeE1 E2: 2E3 E4: 2
Measurement time and arrival time answer different questions

Replacing the Earlier Result

Before E4M1 / 10:00 = 2E4 belongs hereupdate the same rowAfter E4M1 / 10:00 = 3
The revised count replaces 2 with 3 for the same interval

Takeaway: Stream Processing

1Streaming updates ongoing input; a retained log can serve different readers
2Save the next position to resume; use event identity to handle replay
3Measurement time places a late reading in the right interval
← → / Space · S notes · O overview · F fullscreen · number + Enter
Speaker notes