Real-Time Systems and Stream Processing
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Filtering and aggregation as the only two stream operations — covered in Lecture 2
- Events as the fundamental building block of a stream — covered in Lecture 2
- Complex event processing — covered in Lecture 2
- Stream vs batch processing and the bucket-window analogy — covered in Lectures 1 and 2
- Kafka, Spark, and Databricks as streaming platforms — covered in Lecture 1
We start from the data model comparison done earlier: traditional systems and streaming applications model data differently, and that difference matters because it decides everything downstream — how fast we respond, how we classify a system, and whether we can afford to lose a message. The next set of ideas builds directly on that: what makes a system "real time", why response time is one of the most important aspects of stream processing, and how batch processing differs from stream processing. These are not textbook abstractions; each category below was motivated in class by asking "what could you actually lose if a message is delayed or dropped?" — a credit card swipe, a cricket siren, a train signal, a chemical chamber reading.
3.1 Real-Time Systems: Hard, Soft, and Near
3.1.1 The Two Things That Decide Real-Time Performance
Hook: How does a news channel show you what the world is tweeting about right now? Scroll through the trending ticker at the corner of any news screen — those trends come from Twitter. Tweets are ingested, analyzed, and a sentiment analysis (is the mood positive or negative?) is produced almost in real time. Data arrives continuously, and insight must come out fast. That picture — data in, insight out, quickly — is the mental model for everything in this lecture.
When we call this "real-time processing", two things are critical:
- Data ingestion speed — the rate at which data arrives from the various sources. Sources (Twitter, sensors, card swipes) feed data in, and a mechanism must capture that data and send it downstream for processing.
- Processing speed — the rate at which the processing engine handles those messages once they arrive.
The two rates define the system. The latency problem sits between the two: messages arrive at rate (ingestion) and the processing layer consumes them at rate . Every system is only as real-time as its slowest stage — if ingestion is fast but processing is slow, messages pile up; if processing is fast but ingestion is slow, the engine idles. Both rates matter together, and from their comparison the class of the system follows: hard, soft, or near real-time.
Think of a funnel: the top (ingestion) pours messages in, the neck (processing) lets them out. If the neck is narrower than the top, the funnel backs up and latency grows until either the sources slow down or messages are dropped. A real-time system is a funnel sized so that the neck keeps pace with the top — or, if it cannot, the system has decided in advance how much spill it can tolerate.
Scope of the model: these two rates are the throughput view of latency. They describe steady-state behaviour — how fast messages flow, on average, through the pipeline. A system with a huge burst every few minutes may still be fine at the average rate but fail its deadline in the burst; that burst behaviour is exactly where the hard/soft/near classification (next subsections) bites.
3.1.2 Hard Real-Time Systems
Hard real-time system — latency on the order of milliseconds to microseconds, and zero tolerance for delay. Zero tolerance means any lost or late message is a business loss — in the extreme, a life loss. If a single message does not arrive on time, the whole purpose of the system is defeated; there is no room to re-run or re-deliver. The textbook puts it in one line: missing the time requirement can result in total system failure.
Worked example — self-driving car. Image data arrives as messages at regular intervals from the car's cameras. Suppose frames arrive every 30 ms, and one frame showing a pedestrian in the lane is lost in processing. The decision to brake is made from that frame; without it, the vehicle continues at speed and an accident can happen. There is no second chance: you cannot replay the frame after the pedestrian is hit. That single-message failure is why the system must be hard real-time — milliseconds of delay and a lost message have irreversible consequences.
Real-world note: hard real-time systems are almost always embedded — pacemakers, anti-lock brakes, engine control units, surgical robots. They are designed with strict worst-case guarantees (bounded processing time, bounded network delay), which is why the reference book lists them as a category that is well studied but outside the scope of a streaming-data course. When a use case is hard real-time, you leave stream processing entirely (see section 3.4).
3.1.3 Soft Real-Time Systems
Soft real-time system — operates on the time scale of milliseconds to seconds. The key difference from hard real-time is tolerance: how much message loss the system can absorb. In soft real-time, losing some messages is acceptable; it is not a life threat, and no total system failure follows.
Real-world: credit card transactions. Swipe a card and you immediately get a message confirming the transaction with the details and amount, plus a "call customer care if you did not make this purchase" prompt. The classification of this example generated a genuine debate in class — a debate worth preserving, because it is the first time the course's classification rule is exercised under pressure:
Q: The credit card example falls under hard real-time, right? There is no life risk — I agree — but you may also lose business. A: Yes, but the settlement of the credit card transaction happens over a period of 24 hours; it is not instantaneous. So it can be soft real-time. Q: (A follow-up, pushing the same idea) So if it can tolerate a delay in settlement, it is not hard. A: It can be soft real-time. Yes.
The resolution: even though the immediate notification feels instantaneous, the end-to-end business process (settlement) tolerates up to 24 hours of delay, so the whole system is soft real-time. The immediate swipe feedback is one part of the system; the classification follows the tolerance of the entire process, not the snappiest step. This is the moment that established the course rule: classify by the whole process's tolerance, not by the part that feels fast.
3.1.4 Near Real-Time Systems
Near real-time system — works on the time scale of seconds to minutes, "the order of a few minutes". Losing some messages is fine; there is tolerance for delay, and nothing life-threatening follows from a lost event.
Worked example — online vehicle tracking. A live map app shows where a bus or train is located right now. The position shown on the map can lag a few seconds to a few minutes and the app is still useful: a passenger checking where the bus is does not care about a 90-second staleness. There is no control decision riding on the frame — if one position update is dropped, the marker simply freezes briefly and the next update corrects it. No serious risk follows from that lag: it is traceability, not control. That combination — minutes-scale tolerance and no risk — places the system in near real-time.
The mental distinction to carry forward: traceability systems tolerate minutes; control systems do not. If a position update were being used to steer the vehicle, the same data would demand a different class (see sections 3.5 and 3.6).
3.1.5 The Latency-Tolerance Table
| Category | Latency scale | Tolerance for delay | Message loss consequence |
|---|---|---|---|
| Hard real-time | milliseconds to microseconds | zero | message loss = business loss (possibly life loss) |
| Soft real-time | milliseconds to seconds | some | losing messages is not a life threat |
| Near real-time | seconds to minutes (few minutes) | more | a few minutes of delay is acceptable |
The textbook's classification table (table 1.1 of the reference) matches this exactly in the latency ranges and tolerance wording, and adds its own example choices: hard — pacemaker, anti-lock brakes; soft — airline reservation system, online stock quotes; near — video chat, home automation. Notice that the textbook itself calls airline reservation and online stock quotes soft real-time — the same call the professor makes in example 7 below. Where the professor's table says "milliseconds to microseconds" for hard, the textbook writes "microseconds to milliseconds": the same range, just read in the opposite direction.
Exam note: This table is the reference you should always return to when classifying a system. The instruction in class was explicit: "You should always refer to this table because otherwise we will put our own thing." Whenever you are asked to classify a use case, anchor your answer to the latency scale and the tolerance column rather than your intuition. A common exam trap is classifying by how scary the example sounds ("a railway must be hard real-time") instead of by the two table axes.
3.1.6 Classifying Use Cases: Worked Examples
Each example below was worked through live in class, and the classification logic (not just the answer) is the lesson. Follow the reasoning line by line: latency scale → life risk → tolerance → class.
Example 1 — Credit card swipe (soft real-time). The swipe produces an immediate transaction notification — the part that feels fast. But the settlement of the payment happens over 24 hours, so the end-to-end business process tolerates long delay. Latency scale: milliseconds (notification) to hours (settlement); no life risk; tolerance exists. Classification: soft real-time, on the strength of the 24-hour settlement argument from 3.1.3. Sense-check: if settlement had to complete before the shop releases the goods, tolerance would collapse and the class would tighten.
Example 2 — Self-driving cars (hard real-time). Image messages arrive at regular intervals, and a lost or delayed message can cause an accident. Latency scale: milliseconds; zero tolerance, because a missed frame is a missed brake decision. Classification: hard real-time. Sense-check: this is the case where the decision itself is made from the enriched event — the rule that reappears in 3.5.3.
Example 3 — Cricket no-ball declaration (soft real-time). A student proposed it: when a bowler oversteps, a siren sounds and the no-ball with free hit is declared. Is it hard, soft, or near? The no-ball flag after the delivery can tolerate a second or so — the decision does not need to exist before the ball is delivered. But if the decision goes to the third umpire, the time scale grows toward minutes. It is definitely not hard: seconds-scale latency, no life risk. Classification: soft real-time (the seconds-scale answer), with the note that the third-umpire path stretches the scale. Sense-check: no player's life or money hangs on a 2-second flag delay, but the system is still fast enough that minutes would feel broken.
Example 4 — Online traceability of buses and trains (near real-time). A student's example: map-based tracking of vehicles via GPS movement. Delays of a few seconds to a few minutes are acceptable, and there is no risk — it is only traceability, not control. Classification: near real-time. Sense-check: swap "show the bus on a map" for "stop the bus at a signal" and the class would change; the traceability framing is what keeps it near.
Example 5 — Chemical chamber sensors in a factory (depends on the chemical). A sensor keeps sending temperature and pressure messages. The answer depends on the chemical inside the chamber: for a life-threatening substance (say, a toxic gas), a lost reading could mean a missed leak, and the system may need to be hard real-time; for monitoring ordinary physical parameters of a tank (say, cooling water temperature), it can be soft. The type of chemical decides the tolerance, which decides the class. Sense-check: the same sensor hardware, the same message format, two different classifications — the difference is entirely in the consequence of a lost message. This example is where the discussion pivoted into the deeper question of section 3.2: what is the actual purpose of stream data processing?
Example 6 — Temperature monitoring of a smart car (soft or near real-time). Engine messages are tracked. Not hard real-time, because there is time to react: you notice smoke from under the bonnet, stop the car, open it, and find the coolant is over or the water drained. Human intervention is possible, so the system falls under soft or near real-time; then you ask which time scale you are working in — milliseconds, seconds, or seconds-to-minutes. Minutes may be too risky: an engine that overheats to the point of damage does not wait politely for a report. Safer working assumption: seconds → soft real-time. Sense-check: the human-in-the-loop buffer is what rules out hard; the damage risk is what keeps it from sliding fully into near.
Example 7 — Railway reservation and online stock (soft real-time). Both are soft real-time. Online stock is a good warning example: it is not near real-time because the time scale expected is seconds and milliseconds — if the system slips into minutes, you lose money. When money loss is at stake, the classification tightens: the delay tolerance collapses even though there is no life risk. Sense-check: the textbook's own table lists online stock quotes under soft, confirming the same reasoning.
Comparison — the seven cases at a glance:
| Use case | Latency scale | Life risk? | Class |
|---|---|---|---|
| Credit card swipe | ms notification, 24 h settlement | no | Soft |
| Self-driving car | ms | yes | Hard |
| Cricket no-ball | seconds (third umpire stretches it) | no | Soft |
| Bus/train GPS traceability | seconds–minutes | no | Near |
| Chemical chamber | depends on the chemical | maybe | Hard or soft |
| Smart car temperature | seconds safer than minutes | no | Soft (or near) |
| Railway reservation, online stock | seconds–milliseconds | no (money) | Soft |
When to pick which: traceability with minutes of slack → near; any money loss on minutes-scale delay → soft; any life risk → hard.
3.1.7 Student Questions and Answers
Q: For hard real-time systems, do we decide on the basis that no life is at risk? Or could it be business loss or money loss instead? A: It is a combination of both. We look at what the loss is — life, business, or money — and at the latency. Whenever money loss comes in, it cannot be hard; it falls into soft. Q: So it is not always about life? It may be about money loss or something other than life? A: Exactly — not life, other than life too. That is why online stock is soft: in minutes you lose money.
The correction carried in this exchange is the moment the classification stopped being "life risk only" and became "loss type + latency". Hard is reserved for zero-tolerance loss; once money loss enters, the system is pushed out of hard into soft even when no one is at risk.
Q: What is the difference between hard and soft when life is not at risk? A: The differentiation between soft and near real-time happens through the tolerance aspect — high tolerance or low tolerance. When you say no tolerance, that means tolerating the delay could be a life threat. The one thing you always check first is whether there is life risk or no life risk; that part is clear. Combined with latency, these two give you the classification. Q: Is there any other key differentiator besides life risk? A: Generally a streaming system would never wait on something to happen with potential loss of life attached. For any system you just look at tolerance and look at the latency — simple. Based on tolerance and latency together you differentiate whether it is a hard real-time system or not; then, if it is not hard, you ask whether it is near or soft.
The two axes — tolerance and latency — are the entire decision apparatus. Life risk is not a third dimension; it is how the tolerance column is read (zero tolerance of delay because the consequence is life). Everything else is a consequence of these two axes.
3.1.8 The Classification Decision Process
Putting the worked examples together, the systematic process is:
- What is the latency? What time scale are we looking at — milliseconds, seconds, or minutes?
- Is there life risk involved? Zero tolerance (life threat) → hard.
- If not hard, what is the tolerance for delay — high or low? Minutes-scale tolerance → near; seconds-scale → soft.
Scope — where the line is honest and where it is not. The line between soft and near real-time is blurry and not well defined — use cases like the cricket no-ball signal show seconds-to-minutes spans, and the textbook agrees that the soft/near boundary "becomes blurry, at times disappears, is very subjective, and may often depend on the consumer of the data". By contrast, the opening between hard real-time and everything else is wide, because the deciding factor there is unambiguous (life risk / zero tolerance). In an exam, do not spend your time agonizing between soft and near; spend it on the hard check, which is binary.
Pitfalls when classifying use cases:
- Classifying by how fast the visible part feels. The credit card notification feels instantaneous, but the system is soft because of the 24-hour settlement. Always classify the whole process.
- Forgetting the money rule. Money loss is a form of intolerance: online stock is not near real-time just because "trading can wait a minute" — it cannot, and minutes cost money.
- Using intuition instead of the table. The class instruction was explicit: always refer to the latency-tolerance table, or you will substitute your own reasoning.
- Calling anything with a computer "real-time". "Real-time" is a property of the latency scale and tolerance, not of the hardware.
Exam note: Expect a use case in the exam where you must classify the system as hard, soft, or near real-time. The skill being tested is the basis of separation — unless you understand on what basis you separate any event, it is very difficult to produce the right option. Answer by naming the latency scale and the tolerance, then the class. Format: "Latency is seconds-scale and tolerance is low, so this is soft real-time" — the axes first, the label last.
Recap and bridge. A system is hard, soft, or near real-time based on two axes only: the latency scale and the tolerance for delay, with life risk as the hard/not-hard gate. Keep the seven worked examples and the table in mind — the next section asks what stream processing is for in the first place (filtering and aggregation), which is the other half of the lecture's core picture.
Real-world connection. The classification is not classroom bookkeeping; it is how industry buys and builds systems. Autonomous-vehicle stacks budget fixed latencies per stage (perception, planning, actuation) and demand hard guarantees. Payment networks (Visa, Mastercard) run authorization in milliseconds but settle over days — soft real-time in exactly the professor's sense. Transit agencies track fleets with minutes-level freshness — near real-time. And industrial control systems (chemical plants, power grids) size their tolerance by the hazard of the substance in the pipe, exactly as example 5 shows. Whenever an engineer is asked "what happens if a message is late?", they are being asked to run this classification.
3.2 The Purpose of Stream Data Processing: Filtering and Aggregation
3.2.1 The Goal of Data Processing
When a sensor on a chemical chamber streams temperature and pressure messages, what are we actually trying to do? The class's first answer: capture and process each and every event as much as possible. But the deeper point — and the professor's framing for the whole course — is that stream data processing performs only two operations:
- Filtering
- Aggregation
Intuition. You never rewrite the data in a stream. You select part of it, or you summarize part of it — that is all. "We do not modify the data. We do nothing else." The entire job is generating insight, through transformation of the data, aggregation of the data, or filtering of the data. If an operation is neither selecting nor summarizing, it does not belong in a streaming system — a rule that becomes obvious once we see (3.2.4) that streaming systems do not act on the world.
3.2.2 Aggregation
Aggregation means combining many events into a summary number. The in-class example: what is the mean temperature of the chamber in the last five minutes? The professor described the computation in words ("the mean temperature of the chamber in the last five minutes"), and the standard form is the arithmetic mean of the readings inside the window:
Every symbol, named: (T-bar) is the mean temperature — the summary we want; is the temperature reading carried by message in the window; is the number of messages collected in the last five minutes; the index runs from 1 to , so every reading in the window is included exactly once. This matches the standard windowed-average form used throughout the reference texts (the textbook's rolling average over a time window is the same operation with the same formula).
Why the window matters. The five minutes are part of the aggregation: the summary is over exactly the events in that window, no more and no less. Change the window and you change the answer — a mean over the last five minutes is not the mean over the last hour, and a live dashboard hides that difference if the window is not labelled. The window is the aggregation's boundary condition, not an implementation detail.
Worked example — mean temperature over a five-minute window. Suppose the chamber sensor reports one reading per minute and the last five readings are (in °C). With :
Mean temperature over the window: 74.6 °C. Sense-check: 74.6 sits between the smallest reading (72) and the largest (78), leaning slightly toward the hotter readings — a plausible "typical" value for this five-minute stretch. A jump to 80+ on the next report would now be visible against this baseline.
Assumptions & scope. The mean assumes every message in the window counts equally (uniform weight) and that the sensor's readings are comparable numbers. If messages arrive at irregular intervals, the simple mean still works but weights each message equally rather than each second; if the pressure or temperature is drifting fast, a single number hides the trend — that is why windows are usually paired with filters (next subsection) and why real deployments often use richer aggregates (count, sum, min, max) alongside the mean.
3.2.3 Filtering
Filtering means selecting only the events that satisfy a condition. The in-class example: how many messages were received in the past one hour where the pressure equals about 700? That is a filter — a condition on a field — and the count of matching messages is the insight. The condition is a predicate on the event: keep the event if , drop it otherwise.
The filter and the count together are one operation: the filter selects a subset of the stream, and the count summarizes it. The lecture audio garbled the pressure unit (it sounded like "hertz", which is a frequency unit; pressure is measured in bar or kilopascal), but the unit does not matter for the idea — the condition "pressure about 700" is a threshold filter, and any unit plugs into the same predicate.
Worked example — filtering by pressure condition. Over the past hour the sensor sent 3,600 messages, one per second, each with a pressure reading. The condition is bar, say . Counting the messages that pass: 84 of 3,600 match. Insight: 84 messages in the last hour reported pressure about 700. Sense-check: the count answers exactly the question asked — it filters first, summarizes second — and an alarm or dashboard could now act on that count.
Where the filter lives. In practice the filter can sit at different tiers of the pipeline (at the source, in the analysis tier, or at the client), and filtering can be static (fixed at design time, like "only pressure readings") or dynamic (chosen at run time by the consumer, like a dashboard user picking a band of pressures). The lecture's point is simpler and more fundamental: whichever tier runs it, a filter is one of the only two things a stream processor is allowed to do.
3.2.4 Stream Processing Is Not a Control System
The key intuition to keep: the system we are describing is not a control system. A control system would do this: receive a message, analyze it, and send control to someone who stops the chamber or cuts the heat. The streaming system we are discussing does not take action. It only generates insight; after the insight, a human takes action. System generates insight → you take action. The system itself never acts.
That is why filtering and aggregation are the only two operations: they are all you need to produce insight, and they are all you are allowed to do when you are not a control loop. A control system needs a third operation (actuate), which is why the moment a system starts steering — applying brakes, switching tracks — it leaves the streaming family and becomes a (possibly hard) real-time system (sections 3.4 and 3.5).
Recap and bridge. Stream processing selects (filter) and summarizes (aggregate) events into insight, and nothing more — because it generates insight for humans to act on, not actions of its own. Next, section 3.3 asks how the computational model of a streaming system differs from the input-process-output model you already know.
3.3 The Computational Model of Streaming Systems
3.3.1 Input, Process, Output
Every computational model you learned in programming rests on three building blocks: input, process, output. Streaming systems still need all three. What differs is the character of each:
- the input is heterogeneous (3.3.2),
- the process runs over events that arrive continuously rather than sitting in files,
- the output is a set of enriched events consumed by diverse clients (3.3.3).
Intuition. You already know input-process-output from your first programs: read a value, compute, print a result. A streaming system is the same three boxes, with the twist that the input never ends, the sources are many and uncontrolled, and the consumers are many with different tastes. Nothing about the shape of the model changes — only the character of each box.
3.3.2 Heterogeneous Input
Heterogeneous input — the input entering a streaming system comes in different data types. Your data source can be a mobile phone, a Twitter feed, a feedback form, or anything else. We have no control over the source of data or how the data arrives at the system. That is difference number one: the ingestion layer must accept diversity because it does not choose its sources.
Heterogeneous means "made of unlike parts": a temperature reading (a number), a tweet (text), a swipe (an ID plus a timestamp), a form submission (fields), a GPS fix (latitude and longitude). The ingestion layer receives all of these through the same funnel and must accept them without knowing their shape in advance — it is the producer, not the consumer, who decides what arrives. Contrast this with a classic database application, where the application defines its schema and refuses anything that does not fit; a streaming system has no such luxury, because the producers outnumber the system and answer to no one.
3.3.3 Enriched Events and Diverse Clients
Difference number two is on the output side. Once events are processed, the insights we share are called enriched events — raw events with computed insight attached.
Worked example — enriching a train event. The raw event says: "train X crossed station Y at 10:14:22, travelling at 96 km/h." After processing, the enriched event adds the computed insight: "train X is 3.2 minutes behind schedule on line Z." The raw fields (timestamp, station, speed) plus the attached insight (delay status) together form the enriched event that consumers receive. Filtering and aggregation from section 3.2 are exactly what produced the attached insight.
These enriched events go to different clients in different formats. Some streaming clients expect a dashboard rendered on a mobile device; others on a laptop; others a data feed for further analysis. So: different types and formats at the ingestion layer, and different types and formats of requirement downstream. There is diversity in both directions — the diversity of the incoming data types and the diversity of the clientele (the nature of clients and the format they want).
Decoupling. The ecosystem consuming the processed events sits on the right-hand side of the model, and it is disconnected from the devices that produce data. Data producers, data consumers, and the processing unit are all separate, and the consumers consume at their own time scales — consumption does not have to happen immediately after processing. A consumer that went offline at 10:00 can still read the enriched events produced at 10:00 when it returns; the reference book makes exactly this point when it defines a streaming data system as a non-hard real-time service whose clients consume data when they need it.
Recap and bridge. The computational model keeps input-process-output, but the input is heterogeneous (many uncontrolled sources), the output is enriched events (raw events plus computed insight) served to diverse clients that consume at their own pace. Next, section 3.4 places this model in the real-time classification from 3.1: what kind of real-time system is a streaming system?
3.4 Streaming Systems versus Real-Time Systems
3.4.1 Stream Processing Operates in Non-Hard Real Time
Streaming data systems are expected to work in a non-hard real-time manner. The reference book states this as the very definition of a streaming data system: a non-hard real-time computation whose clients consume the data when they need it, not when it is produced. This triggered a clarifying question in class:
Q: Does this mean that in a hard real-time system there cannot be a streaming data system? A: Stream processing means it is not hard real-time — it is a non-hard real-time system. There is no streaming in hard real-time systems; that is a real-time system, not a streaming system. Everything is not stream processing.
The picture: we take stream processing, "double-click" it, and inside we find a couple of options — soft real-time and near real-time. The difference between soft and near is blurred; the difference between hard and the rest is a wide opening. Hard real-time systems are a separate category from stream processing.
The family tree. Stream processing contains exactly two of the three classes from 3.1 — soft real-time and near real-time. Hard real-time is not a third option inside the folder; it is a sibling folder entirely. When the professor "double-clicks" stream processing, the menu that opens shows soft and near, never hard.
3.4.2 Can a Hard Real-Time System Be a Streaming System?
Q: So there will be no streaming in hard real-time systems at all? A: No streaming — not real-time systems. It only says that this is not a streaming system; it is a real-time system. We differentiate them in terms of time scales, and it is a little bit difficult to categorize, but the life-risk check separates them: if we are in hard real-time we have a risk or potential loss of life, which is not a factor for any streaming system. There is no streaming system which would wait on something to happen with potential loss of life.
The reasoning, made explicit: hard real-time is defined by zero tolerance and potential loss of life, and its decisions are made from the enriched event itself (3.5.3). A streaming system, by contrast, generates insight for a human to act on — a human waiting is exactly what a hard real-time system cannot afford. "There is no streaming system which would wait on something to happen with potential loss of life" is the professor's one-line proof: if life depends on the message, no analytics layer may sit in the path.
Pitfall — calling the hard system "streaming". A self-driving car processes a continuous flow of camera frames, which sounds like streaming. It is not. The deciding test is not "does data arrive continuously?" but "does a delayed message risk life or total failure?" If yes, the system is hard real-time, and hard real-time is not a streaming system — however frame-like the data looks. The word "stream" describes the delivery; the word "real-time" describes the guarantee. They are different axes, and the professor's point is that a hard real-time system sits at the extreme of the guarantee axis where streaming does not operate.
Recap. Real-time systems (hard) and streaming systems are different families. Streaming systems live in the soft/near region; hard real-time is its own category defined by life risk and zero tolerance. Keep this separation ready — section 3.5 builds the rule that decides which side of the line a specific system lands on: whether a decision is taken from the enriched event.
3.5 Complex Event Processing
3.5.1 The CCTV Worked Example
Hook. A single traffic camera frame says "a bicycle crossed this junction". Two frames, thirty minutes apart, can say "a robbery is in progress and the police are in pursuit". How does insight arrive from events that, alone, mean almost nothing? That is the question complex event processing answers.
The motivation came from a traffic-tracking scenario. We take snapshots of images at regular intervals — CCTV footage. Suppose the footage shows two people riding a bicycle crossing a location at 10 o'clock, and the two-wheeler moved out at about 100 kilometers per hour. In the next lane, after about five minutes, a police jeep with a siren crosses the same location — the CCTV footage of that arrives after five minutes.
Worked example — combining CCTV frames into a chase. Two sets of images:
- Frame set A (10:00): a fast-moving two-wheeler at 100 km/h crosses the junction in the first lane.
- Frame set B (10:05): a police jeep with siren crosses the same location in the next lane.
Neither frame set, taken alone, says anything unusual: fast two-wheelers exist, police patrols exist. But combined — a 100 km/h vehicle at time , a police siren at the same spot at roughly minutes — the events imply a pattern: a robbery happened, and the police are chasing those people. The inference is drawn from the combination across time, and that inference is the insight no single frame contains. That kind of inference — drawing a conclusion from combining events across time — is called complex event processing (CEP). Sense-check: change the gap to five hours and the inference dies (no one is chased for five hours); the time correlation between the two events is what carries the meaning.
The reference book describes CEP in the same terms: an approach, developed in the 1990s, for analyzing event streams by searching for certain patterns of events — the way a regular expression searches for patterns of characters in a string, CEP searches for patterns of events in a stream. The rules describing the pattern are kept long-term, the events flow past them continuously, and when a match fires, the engine emits a complex event carrying the details of the pattern it detected.
Real-world connection. CEP is the technique behind correlation-style analytics — separate, apparently unrelated events in a stream are correlated to infer something none of them says alone. Industrial deployments: credit-card fraud desks (a purchase in city A followed minutes later by one in city B), bank anti-money-laundering systems (two linked transactions within a short window), surveillance and safety systems (the CCTV case), and trading systems that detect order patterns. Named CEP engines in the field include Esper, IBM InfoSphere Streams, Apama, and TIBCO StreamBase.
3.5.2 CEP Runs in Seconds to Milliseconds
What matters most for CEP is the time scale you operate in. In the CCTV example the time scale is seconds and milliseconds — not minutes, because by the time minutes pass, the people will have run away. A time scale of seconds/milliseconds with no life risk puts CEP in the soft real-time category.
CEP's time budget. The inference is only useful inside a window: the two-wheeler and the siren must be correlated within seconds-to-minutes of each other, and the alert must leave the system before the chase ends. That fixes the latency scale (seconds, at most low minutes) and, with no life risk attached, the class is soft real-time. The combination window (how far apart events can be and still be correlated) and the processing latency (how fast the correlation must run) are the two numbers that size a CEP deployment.
3.5.3 Student Questions and Answers
The self-driving car case was used to draw the line between insight and action:
Q: For self-driving cars, the analysis gives the direction for the next movement of the vehicle. Isn't the decision based on the enriched event? When the car encounters an object (a person), it must be hard real-time, right? A: Agreed. If your decision is taken based on the enrichment of the event, it becomes hard real-time. But if your decision is to enrich the event and get analytics out of it, then it is not hard real-time. Q: So it depends on the context — monitoring to switch a track is a different case from applying brakes? A: Yes. Decision making depends on the use case. For the train: a normal train (not self-driving) where we enrich events and check for congestion at an upcoming point needs soft real-time. If manual control is involved, it is not hard real-time.
The cleanest rule of the lecture: decision based on the enriched event → hard real-time; decision that only enriches the event for analytics → not hard real-time. Before classifying any system, ask one question: does something act on the enriched event, or does a human read the insight? Acting on it — braking, steering, switching tracks — is hard real-time territory; reading it is stream processing.
Pitfalls:
- Confusing the frame rate with the guarantee. CCTV looks at frames continuously, but nothing in the system brakes or steers from a frame; the correlation simply informs a dispatcher. Continuous data in does not mean hard real-time.
- Classifying CEP as near real-time. Because the correlation involves "events five minutes apart", it is tempting to call it near real-time. The professor's answer is the opposite: the processing must complete in seconds-to-milliseconds or the chase insight dies, so CEP is soft real-time.
- Forgetting the action test. The same enrichment pipeline (a train event) is soft real-time when a human reads it and hard real-time when the enriched event directly actuates a driverless vehicle (see 3.6.3). The pipeline did not change; the decision path did.
Recap and bridge. CEP is correlation across time — combining events into inferences none of them carries alone — and it runs at a seconds-scale, soft real-time pace, because its value dies with delay. The action test from this section now carries into section 3.6, where the train tracking case study applies it to decide soft versus near.
3.6 The Train Tracking Case Study
3.6.1 The Train Event
The running example: track the geographic location of a train for decision making. What is the event? The event carries:
- timestamp — when the reading was taken
- longitude — the east–west coordinate of the train
- latitude — the north–south coordinate of the train
- which station it crossed recently
- the speed of the train
That event is the message flowing into the processing system.
Worked example — a train event payload. One message from a Rajdhani train on the network:
| Field | Value |
|---|---|
| timestamp | 2026-03-14 10:14:22 IST |
| longitude | 77.2090° E |
| latitude | 28.6139° N |
| last station crossed | New Delhi |
| speed | 96 km/h |
The processing system does not care whether this payload arrived from the train's GPS unit, from a trackside sensor, or from a mobile tower handoff — it accepts the heterogeneous input (3.3.2), reads the five fields, and produces the enriched event (3.3.3): "train at these coordinates, on time, moving at 96 km/h." The event is the unit of work; the enrichment is the unit of insight.
3.6.2 Soft or Near? The Minutes Question
Classification process applied: the latency is not milliseconds — there is some bandwidth (time slack) — so it comes under the second category. But is it soft or near?
Q: I'm inclined towards near real-time — can it go in the order of minutes? That is the only question. If it can go in the order of minutes, then near real-time; if not, then soft. A: We need to decide. It can be minutes, but the reaction time is important. If you give a signal, the train has to travel and move in a different direction — that big machine takes time to move. And you are not tracking one train: Rajdhani trains, super fast trains, and others all run on the network, so you need to take the least common denominator of all the trains. Especially for metros, you look at a section: how many trains are running within the section, and you navigate between them. The signal has to come directly to the train, so it cannot be in minutes — the train has to receive it quickly enough to have time to react.
The reasoning chain: the event can tolerate minutes (a stale position is not dangerous by itself), but the decision cannot — a routing or signaling decision must reach the train while there is still time for the train's inertia to respond. A train is a big machine: braking and changing direction take seconds of physics, so the decision must arrive well before the deadline. And the network is not one train: Rajdhani, super fast, and local trains share the track, so the system must be sized to the slowest-reacting, fastest-moving worst case (the "least common denominator" of all the trains). The direct signal path — control to the train itself — forbids minutes.
Q: But there is potential loss of life — two trains can collide if we fail between the trains. Why is it not hard real-time? A: The railways have a whole infrastructure already in place; you are not running your entire railway line based on your stream processing system. The purpose here is to analyze the data, to monitor and control — this is a use case of monitoring train messages. Compare with self-driving cars: there, based on the analysis you give the direction to the next movement of the vehicle, so it has to be hard. Here you don't give instant input based on the processing of the event.
The life-risk objection fails on the action test from 3.5.3: collision safety is handled by the existing railway infrastructure (signaling, block sections, interlocking) — not by the stream processing system. The stream system enriches and monitors train messages for a human controller; it does not directly actuate the brakes. Compare the self-driving car, where the enriched event is the brake command: there the analysis feeds the next movement directly, and the system must be hard. Here, you do not give instant input based on the processing of the event.
So the classification: the train tracking system is soft real-time — a student first said near real-time; the resolution is that the reaction time of the train plus the direct signal path pulls it back from minutes.
Pitfall — "minutes of slack" in the event vs "minutes of delay" in the decision. A position that is five minutes old is still useful for tracking (that suggests near real-time), but a routing decision five minutes old is useless or dangerous (that forces soft). The trap is classifying by the tolerance of the data instead of the tolerance of the decision path. The professor's phrasing to remember: "The signal has to come directly to the train, so it cannot be in minutes."
3.6.3 Driverless Trains
A further nuance on the same example:
Q: If the train is purely autonomous — some trains do have this — can it become hard real-time? A: Yes. If manual control is involved, it is not hard real-time. If it is purely autonomous (driverless), it can become hard real-time. When we say "train", it is soft real-time; the distinction is driverless train versus driver-controlled train.
The driverless flip. The moment the enriched event actuates the train itself — no human in the loop — the action test flips the classification: driver-controlled train → soft real-time (human reads the insight); driverless train → hard real-time (the insight is the command). This is the same flip as the self-driving car in 3.5.3, applied to the train case study: the system did not change, the decision path did.
Real-world connection. Metro systems running driverless operation — the CBTC-based metros mentioned in the discussion, communications-based train control, where trains continuously communicate their position to a control center and receive movement authority over radio instead of relying on fixed signals alone — operate closer to hard real-time than classic driver-controlled rail, because their enriched events feed automatic train protection directly. The same technology family, from classic block signaling to CBTC, is exactly the "existing infrastructure" that keeps the monitored-train case soft in 3.6.2.
Recap and bridge. The train case study shows the full classification machine working on one example: event fields (3.6.1), the minutes question (3.6.2), and the driverless flip (3.6.3) — ending in soft real-time for monitored trains and hard real-time for autonomous ones. Section 3.7 now leaves real-time classification behind and compares the batch world: what changes when you stop processing events as they arrive and collect them instead?
3.7 Batch Processing
3.7.1 What Batch Processing Is
Batch processing means capturing events and processing a collection of events together as a group, rather than processing each event the moment it arrives. It is how you process high-volume data — for example, collecting group transactions or high-volume invoice data. Events are collected for a specified timeframe, and at the end of the timeframe the whole collection is sent to the processing engine, which generates insights and dashboards.
Intuition — the bucket in the stream. Picture standing by a river with a bucket. Stream processing dips the bucket in and reads the water passing now. Batch processing holds the bucket in the water for a fixed time, then lifts it out and examines everything it caught. The examination is deeper (you have the whole catch in front of you), but you only get answers at lift-out times. That trade — deeper answers, later answers — is the entire batch story.
3.7.2 The Six-Hour Batch Walkthrough
Worked example — batches B1 and B2. Consider events arriving continuously (say, one purchase event every second). We take a group of events and call it batch B1, process them as a single batch, and get insights. The next collection becomes batch B2. The schedule: collect events for a specified timeframe — say six hours — so:
- 00:00–06:00 → batch B1 contains every event from those six hours; the engine processes B1 at 06:00 and returns the insights.
- 06:00–12:00 → batch B2 contains every event from the next six hours; the engine processes B2 at 12:00.
Every batch that runs contains all events collected over the last six hours. A purchase made at 03:00 does not appear in any dashboard at 03:00; it waits in storage until 06:00, when B1 fires. The batch is scheduled; it is not true that when an event arrives it is immediately processed. Events sit in storage until their batch fires. Sense-check: the freshness of batch insights is bounded below by the batch period — six-hour batches can never answer a question "as of the last second", which is precisely the gap stream processing fills.
3.7.3 The Bucket Analogy: Time-Based and Count-Based Windows
The water-bucket analogy explains the two ways to decide what goes into a batch. Imagine putting a bucket into a stream of water:
- Water-level way (count-based): collect water until it reaches a certain level inside the bucket — the batch fills up to a fixed number of events.
- Stopwatch way (time-based): start the stopwatch when the bucket enters the water, and remove it when the stopwatch says the time is up — the batch collects everything that arrives in a fixed time span.
Both are batch. In both cases you are collecting only a sample from the stream — a subset of everything that ever flows. The professor confirmed this explicitly: "Can a batch trigger on the number of events?" — yes, that is the special window (the water-level way). It does not have to always be time based. The trigger criterion (time vs count) is a design choice; the fact that you process a collected group at a scheduled moment is what makes it batch.
Count-based windows shine when event rates are steady (every batch has a predictable size); time-based windows shine when the metric is "per hour" regardless of volume. The catch with a pure count window is that a quiet period fills it slowly — the batch period becomes variable, and a very quiet period may delay insights past their usefulness.
3.7.4 Batch Is Always Scheduled
The key differentiator between batch and stream processing: batch processing is always a scheduled activity. The payroll example: you run the payroll script only every day at the end of the day — five or six o'clock in the evening. All such scheduled activities fall under the umbrella of batch processing. On the other hand, where you need just-in-time insights and do not want to store events together, you use stream processing.
The schedule is the contract: the collection window (how much data), the firing time (when processing runs), and the output generation are all fixed in advance. Nothing about batch is reactive; the engine runs because the clock says so, not because data arrived.
3.7.5 Student Questions and Answers
Q: On the payroll example — isn't it done monthly, like one day in advance at the end of the month? A: No — payroll can also be done daily if there are daily workers. That's right.
The point of the correction: "scheduled" does not mean "monthly". The schedule is whatever the business needs — daily for daily-wage workers, monthly for salaried staff. What makes payroll batch is that it runs on a fixed schedule over accumulated events, not that the period is long.
Q: Is the batch trigger always time based, or can it also be the number of events? A: Yes, it can be the number of events — that is the special window. It is not always time based.
Two triggers, one conclusion: time-based (the stopwatch way) and count-based (the water-level way) both produce batches; the professor's "special window" is the count trigger. This is a favorite exam trap: students answer "batch is time-based" and lose the count-based special case.
Assumptions & scope — when batch is the wrong tool. Batch assumes the insight can wait until the schedule fires. It also assumes you can store the collection until then — batch needs auxiliary storage for the waiting events, and the bigger the window, the more storage. Where insight must be just-in-time (fraud alerts, live dashboards), or where storage is scarce, batch is the wrong tool and streaming takes over — that trade is quantified in section 3.8.
Recap and bridge. Batch collects events into groups (time- or count-triggered), stores them, and processes them on a fixed schedule — deeper analysis, later answers. Section 3.8 turns the batch-versus-stream contrast into a precise four-way comparison.
3.8 Batch versus Stream Processing: Four Differentiators
The comparison was summarized in four parameters. Stream processing: continuous input, data processed in small time scale, no storage required (messages are not accumulated — data is processed as and when the system is available). Frameworks like Storm and Spark are basically micro-batch processing in this spectrum. Examples of stream processing: ATM bank transactions; processing happens in fixed timelines with a data collection window and a data eviction window.
The four differentiators. Batch and stream processing differ along exactly four axes, all of which the lecture compared in one sweep:
- Data scope (3.8.1) — how much of the main stream the analysis covers.
- Data size (3.8.2) — how many events sit inside the current window or batch.
- Time scale / latency (3.8.3) — the performance dimension.
- Depth of analysis (3.8.3) — complex, comprehensive analysis vs event enrichment.
The fourth axis (depth of analysis) is worth restating, because in the source it was compressed together with the third (latency): the two candidates the professor names in the same breath are time scale and depth of analysis, and both are counted. Keep all four in this exact list for the exam.
3.8.1 Data Scope
Data scope is how much of the data you process: are you processing the entire dataset, or a sample of it? If you process most of the data, that is batch processing. Stream processing deals with a small fraction of the data — the fraction considered in the current analysis is very small, because you do not have the capacity to process everything.
Intuition — the fraction under the lamp. Scope answers "what share of the stream is under the processing lamp right now?" Batch puts nearly the whole accumulated stream under the lamp at once; stream processing moves a small lamp over the stream, illuminating only what passes in the current window. The data under the lamp at any instant — not the data that ever existed — is the scope question.
3.8.2 Data Size
Data size is the window size or batch size — within the batch or window, how many events do you have? It is related to but different from data scope: scope is about how much of the main stream you collect (the sample size); data size is how many events sit inside the current window or batch.
Scope vs size, precisely. Scope = fraction of the whole stream collected (a fraction, dimensionless — "most of it" vs "a tiny part"). Size = the absolute number of events inside the current processing unit (a count — "84 events in this hour's window"). A batch with a huge scope also has a huge size; a stream window with a tiny scope still has a concrete size (its count of events). The professor's warning: "You need to know how much data is within the batch (data scope), and how many events are within the window (data size). These two are slightly different."
3.8.3 Time Scale and Depth of Analysis
The performance dimension is the time scale / latency: batch runs on a schedule (hours, daily), stream processes in small time units (seconds-to-milliseconds per event). And the depth of analysis differs: batch processing does complex analysis, and the analysis is more comprehensive — why? Because you have a lot of data. Batch processing is definitely more accurate and more comprehensive than the insights generated by stream processing, because stream processing only does enrichment of events; it cannot do detailed analysis since it has no mechanism to store all the data.
Scope — the accuracy claim, stated with its condition. "Batch is more accurate" is a statement about what you can compute, not a law of nature. It holds because batch has all the data (the full scope) and the time to run complex analysis over it; stream has a small scope and no storage, so its analytics are limited to filtering, aggregation, and enrichment (section 3.2). If the stream processor could hold everything, the accuracy gap would close — but it cannot, and that is the point. In a comparison question, the correct pairing is: batch → full scope, complex analysis; stream → small scope, enrichment.
Comparison — batch vs stream on the four axes:
| Axis | Batch | Stream |
|---|---|---|
| Data scope | most of the data (large fraction) | small fraction of the stream |
| Data size | large (all events in the window) | small (events in the current window) |
| Time scale / latency | scheduled: hours to daily | small time units, continuous |
| Depth of analysis | complex, comprehensive, accurate | enrichment of events only |
| Storage | required (events accumulated) | not required (process as it arrives) |
When to pick which: need deep analysis of everything with answers on a schedule → batch; need just-in-time insight with small analysis over what passes → stream.
3.8.4 Student Questions and Answers
Q: On data scope — does batch processing ensure all the data is covered in the processing, whereas stream processing uses a rolling time window? A: Correct, correct. And yes, in stream processing you can miss some data or ignore some data — it is possible; you might lose some data. Q: But it is a rolling window — you scan the first four messages, then the next four messages, like that — so data is not really missed, no? A: It is not about missing the data; it is about how much fraction of the data is being considered in the current analysis — that fraction is very less, because you don't have so much capacity for processing. On the other hand, the data scope of batch processing is more sizable. Batch needs auxiliary storage: you store the events, accumulate them, and later run the batch on them. So you need to know how much data is within the batch (data scope), and how many events are within the window (data size). These two are slightly different.
The correction preserved here is subtle and easy to flub: the rolling window does eventually scan every message (the lamp does visit the whole stream), so "stream misses data" is the wrong objection. What is true is that each individual analysis covers only the tiny fraction inside the current window — the lamp's circle, not the river. The scope of the current analysis is small; the stream itself is not fully processed in any single pass.
Worked example — the rolling-window trace. Four messages arrive per second: in second 1, then in second 2, and so on. A count-based window of size 4 processes , evicts them, then processes . Over the long run, every message passes through some window — so nothing is permanently skipped — yet each window's analysis covers only 4 of the stream's millions of events. Scope is small (a tiny fraction per analysis); total coverage is complete (the windows tile the stream). Sense-check: this is exactly the student's question from above, resolved with the professor's answer — the fraction under the lamp is tiny, even though the lamp visits everything.
Recap and bridge. Batch and stream differ on data scope, data size, time scale, and depth of analysis — with storage as the enabling difference underneath (batch stores and accumulates, stream processes as it arrives). Section 3.9 names the industrial frameworks that implement this spectrum, and section 3.10 closes the loop by asking why you would choose stream processing at all.
3.9 Processing Frameworks
3.9.1 Storm, Spark, and Kafka
The main frameworks named for processing stream data: Storm, Spark, and Kafka. Storm and Spark are described as micro-batch processing frameworks. These are the platforms used across the industry, and the ones you will be asked to explore in assignments.
A quick orientation on what each does, since the assignment asks you to explore them:
- Apache Storm — a stream processing framework that handles data tuple at a time (tuple = one message, one event), designed for low-latency real-time processing. Its mental model is a topology: spouts emit events, bolts transform or aggregate them, and events flow through the topology continuously.
- Apache Spark / Spark Streaming — treats the stream as a series of small batches. Spark Streaming divides the incoming stream into micro-batches over short intervals (down to sub-second) and runs a batch job on each — which is why the lecture places Spark on the micro-batch end of the batch-stream spectrum.
- Kafka — the distributed log / messaging platform at the front of the pipeline: producers write events to a durable log, consumers read from it at their own pace. Kafka is the decoupling layer that lets producers and consumers of section 3.3.3 operate on their own time scales.
The industry pattern that emerges: Kafka holds the stream, Storm or Spark Streaming processes it, and downstream systems consume the enriched results. The reference texts confirm this division — the analytics frameworks named there (Apache Storm, Spark Streaming, Samza, Kafka Streams, Flink) sit on top of exactly this kind of log, and the lecture's list of Storm, Spark, and Kafka is the standard trio for this pipeline shape.
3.9.2 The Exploration Assignment
As part of assignments, you will be given platforms like these and asked to explore them and generate insights. You will look at what the platform does and evaluate it — on what basis you evaluate it will be explained, but you need to explore the different data architectures based on the rubric given.
How to study these platforms. For each framework, ask the same four questions — they map directly onto the four differentiators of section 3.8: (1) What fraction of the stream does it analyze at once (data scope)? (2) How many events fit in its window or batch (data size)? (3) What latency does it promise (time scale)? (4) What can it compute — full analysis or event enrichment (depth of analysis)? A framework that buffers and batches (Spark Streaming) answers differently from one that passes events one at a time (Storm), and that difference is the evaluation rubric in miniature.
Recap and bridge. Storm, Spark, and Kafka are the industrial trio: Kafka moves the stream, Storm and Spark Streaming process it (with micro-batching), and downstream consumers receive enriched events. Section 3.10 steps back from the how to the why: four reasons a designer chooses stream processing over batch.
3.10 Why Stream Processing: Four Reasons
3.10.1 The Nature of Data: A Never-Ending Stream
Reason one: the nature of the data itself. Events arrive as a never-ending stream. With batch processing, some events fall into one batch and other events into another batch — so you may lose collective intelligence: by combining events across batches you could get a more accurate insight than any single batch gives.
Intuition — the puzzle split across boxes. Suppose event A says "two-wheeler at 100 km/h" and event B, minutes later, says "police siren at the same spot" (the CCTV case from 3.5). If A lands in batch 1 and B lands in batch 2, the correlation between them is invisible — no single batch contains both. The stream's collective intelligence lives across events, and a batch boundary can split the story. When the data is born continuous, cutting it into fixed boxes throws away the cross-box meaning; that is reason one to process it as a stream.
3.10.2 Time Series Data
Reason two: time series data. If your input data is time series data, stream processing is appropriate.
What is time series data? The stock market is the classic example: for a particular stock, the price is a function of every second, millisecond, and minute. In mathematical terms:
where is the stock price and is time measured on the scale of milliseconds, seconds, or minutes. The professor described the relationship in words ("the price of the stock is a function of every second, millisecond and minute"), and is the standard way to write exactly that: price is a value that changes continuously over time, and that continuous dependence is what makes it time series data. The function maps each instant to a price ; there is a price at every , and consecutive prices are related — the price at is never far from the price at .
Worked example — a price as a function of time. A stock's price sampled at one-minute ticks: , , , and so on. As a time series, each reading is a point on the curve . Now ask a streaming question: "what is the mean price over the last 5 minutes?" — that is aggregation (3.2.2) over the window . Ask a batch question — "what was the weekly pattern of this stock?" — and the answer needs the whole month stored first. The same data supports both, but the time series's continuous arrival is what makes the streaming question the natural one. Sense-check: a price feed that waited until 6 p.m. to be processed would be useless to a trader by 6 p.m.; the value of decays with 's age.
3.10.3 Storage and Infrastructure Limits
Reason three: hardware and other limitations to store events. If you have lesser infrastructure, and only approximate insights are enough for the enrichment of these events, then stream processing is the right choice — you process what you can, when it arrives, instead of storing everything.
Scope — when the limit decides. Batch assumes you can store the collection until the schedule fires (3.7). When storage and compute are scarce — a small server farm, an edge device, a sensor gateway — the cost of holding every event for the nightly batch may exceed the value of the deeper analysis. Stream processing trades comprehensiveness for immediacy: it enriches what passes now, drops the rest, and accepts approximate insights in exchange for not owning a data warehouse. The decision is a budget question: storage is expensive, timeliness is valuable, so process-and-discard wins.
3.10.4 The Data Source
Reason four: the source of the data. If the data is generated by IoT devices or other monitoring systems, you probably go for stream processing.
Sensors, smart meters, vehicle telemetry, wearables, and industrial monitors are built to emit continuously and cheaply — a Raspberry-Pi-class gateway emits readings by the second, not by the batch. Two properties push IoT streams toward stream processing: the sheer event rate (a fleet of devices outproduces any scheduled collection's usefulness window) and the monitoring use case itself (the insight is "is something wrong right now?", which is inherently per-event, not per-month). When the source is a monitoring system, the question it answers is a streaming question.
Comparison — the four reasons at a glance:
| Reason | One-line version |
|---|---|
| 1. Nature of data | Never-ending stream; batch boundaries destroy cross-batch collective intelligence |
| 2. Time series data | Value is a function of every tick (); continuous data wants continuous processing |
| 3. Storage/infrastructure limits | Can't store everything; process what passes, accept approximate insight |
| 4. The data source | IoT and monitoring systems emit by the second; their questions are per-event |
When to pick which: any one of the four being true is a working argument for stream processing; all four true together is the definition of a streaming-native workload.
Recap and bridge. Four reasons justify streaming: the never-ending nature of the data, time series data (), storage and infrastructure limits, and IoT/monitoring sources. Section 3.11 closes the lecture by listing the concrete sources and use cases of streaming data in industry.
3.11 Streaming Data: Sources and Use Cases
3.11.1 Data Sources
The various data sources for streaming: smart devices, IoT devices, mobile phones, and so on. Recall from 3.3.2 that these sources are heterogeneous and uncontrolled — the ingestion layer accepts whatever they emit, in whatever format and at whatever rate. A phone, a smart meter, and a connected car all produce streams, and all three feed the same kind of pipeline: capture, filter or aggregate, enrich, deliver.
3.11.2 Use Cases
The use cases of streaming data named in class:
- Financial institutions — the typical example of time series data (the stock market case from 3.10.2, run at milliseconds-to-seconds scale).
- Sensors in transportation vehicles — vehicle telemetry streams (the smart-car temperature monitoring from 3.1.6).
- Identification of defects — detecting anomalies from streaming sensor readings (a monitoring-system source, 3.10.4: a reading outside its normal band flags a failing part before it breaks).
- Twitter messaging and sentiment analysis — the trending-events use case from 3.1.1, where tweet volume and mood are aggregated into the news ticker.
- Flight tracking — position streams from aircraft (near real-time traceability, like the bus tracker of 3.1.4).
- ATMs and bank transactions — stream processing in fixed timelines, with a data collection window and a data eviction window (the ATM example of 3.8).
- Geolocation tracking of trains — the case study from 3.6, where the enriched event is the train's timestamp, coordinates, station, and speed.
The pattern behind the list. Every use case above is one of the lecture's running examples restated as an industry sector: time series data (finance), monitoring sources (transport, IoT), traceability (flights, trains, buses), and text streams (Twitter). If you can name the reason from section 3.10 that drives a use case, you can produce the streaming choice on any unseen example.
Real-world connection. This is why banks, transit operators, and industrial plants run streaming platforms — the data is born continuously, and insight loses value by the minute. A fraud model fed by ATM and card streams must score each transaction before the settlement window (soft real-time, 3.1.3); a metro control room must see every train's enriched event within seconds (3.6); a chemical plant must filter and aggregate chamber readings to catch the first anomaly (3.2). The stream is not an exotic technology choice — it is what the data's own nature demands, which is the lecture's closing point and the lead-in to the architectures that come next.
Exam Guidance Summary
- Expect a use case classification question: given a scenario, classify the system as hard real-time, soft real-time, or near real-time. The exam tests whether you understand the basis of separation, so answer with the two axes — latency scale and tolerance for delay — plus the life-risk check. Answer format: name the latency scale, name the tolerance, then the class.
- Always refer to the latency-tolerance table (3.1.5) when classifying; the guidance was explicit that otherwise you will substitute your own reasoning. Reproduce the table from memory: hard = milliseconds–microseconds with zero tolerance; soft = milliseconds–seconds; near = seconds–minutes.
- Key distinctions to be able to reproduce: hard = milliseconds–microseconds, zero tolerance; soft = milliseconds–seconds; near = seconds–minutes. Money loss pushes a system out of hard into soft; life risk pushes it into hard. The soft/near boundary is blurry; the hard boundary is not.
- Be able to state the rule: decision based on the enriched event → hard real-time; analytics-only enrichment → not hard real-time (self-driving car vs train tracking; driverless train vs driver-controlled train).
- Know the two operations of stream processing: filtering and aggregation — and the point that stream processing is not a control system (it generates insight; a human takes action).
- Know that streaming systems are non-hard real-time: stream processing contains soft and near real-time, and hard real-time is a separate family (no streaming in hard real-time systems).
- Know the four differentiators between batch and stream processing (data scope, data size, time scale/latency, depth of analysis) and the two batch triggers (time-based and count-based — the "special window").
- Know the four reasons for choosing stream processing (nature of data, time series, storage/infrastructure limits, data source) and the four sources of streaming data (smart devices, IoT devices, mobile phones, and more).
- Reference book: Real-time Analytics by Byron Ellis — one book is enough; it is the course textbook for this material. Its real-time classification table matches the lecture's latency-tolerance table.
- Roadmap: architectures and streaming data come next.
Key Industry Applications
- Twitter trend feeds and sentiment analysis — near real-time text analytics powering the trending tickers on news channels (3.1.1).
- Credit card transaction alerts — instant notification with 24-hour settlement, a soft real-time system (3.1.3).
- Self-driving vehicles — hard real-time image-message processing where a lost message can cause an accident (3.1.2, 3.5.3).
- Live vehicle tracking (buses, trains) on maps — near real-time GPS traceability (3.1.4).
- Stock market feeds — soft real-time (milliseconds to seconds), where minutes-scale delay means lost money (3.1.6, 3.10.2).
- Chemical plant chamber monitoring — filtering and aggregation over temperature/pressure messages; classification depends on the hazard of the chemical (3.2).
- Smart car temperature monitoring — soft/near real-time with human intervention time (3.1.6).
- CCTV-based complex event processing — correlating frames (fast two-wheeler, police siren minutes later) to infer robberies in progress (3.5).
- Railway signaling and tracking — soft real-time enrichment of train events; driverless (CBTC-based) metro operation approaches hard real-time (3.6).
- Payroll processing — the canonical scheduled batch job, daily or monthly (3.7).
- Storm, Spark, Kafka — the industrial micro-batch/streaming platforms used for the frameworks assignment (3.9).
- IoT device and monitoring-system streams — the data-source reason for choosing stream processing, driving fraud detection, defect identification, and flight tracking (3.10.4, 3.11).
SPA Lecture 03 notes · Real-Time Systems and Stream Processing
Sections Breakdown
Classifying systems as hard, soft, or near real-time by latency scale and tolerance for delay, with seven worked use cases.
Filtering and aggregation as the only two stream operations; stream processing generates insight, not control actions.
Heterogeneous input, enriched events as output, and diverse decoupled clients in the input-process-output model.
Stream processing covers soft and near real-time; hard real-time is a separate family, not streaming.
Combining events across time into inferences (CCTV chase) at a seconds-scale soft real-time pace.
The train event fields, the minutes question, and the driverless flip between soft and hard real-time.
Scheduled collection and processing of events; time-based and count-based triggers; the six-hour batch walkthrough.
Data scope, data size, time scale, and depth of analysis, with storage as the enabling difference.
Storm, Spark, and Kafka and how to evaluate any framework on the four differentiators.
The nature of the data, time series values, storage limits, and IoT sources justify streaming.
Smart devices, IoT devices, and mobile phones as sources; industry use cases across finance, transport, and text analytics.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Real-Time Systems: Hard, Soft, and Near
Must-know: Classify by latency scale + tolerance: hard = ms-to-ms, zero tolerance, life risk; soft = ms-to-seconds, some tolerance, money loss; near = seconds-to-minutes, high tolerance. Always refer to the latency-tolerance table.
⚠️ Top pitfall: Classifying by how fast the visible part feels (credit card notification) instead of the whole process's tolerance (24-hour settlement); forgetting the money-loss rule that pushes stock/railway reservation to soft.
Self-check: A live bus-tracking map can lag 2 minutes with no harm — which class?
Connects to: 3.4, 3.5, 3.6 (other concepts in this lecture).
The Purpose of Stream Data Processing: Filtering and Aggregation
Must-know: Stream processing performs only filtering and aggregation; it is not a control system — it generates insight and a human takes action. Windowed mean: \bar{T} = (1/n) sum of T_i over the window.
⚠️ Top pitfall: Describing stream processing as 'modifying data' or 'taking action' — both are forbidden; only select and summarize, and the system never actuates anything.
Self-check: What are the only two operations a stream processor may perform?
Connects to: 3.3, 3.4 (other concepts in this lecture).
The Computational Model of Streaming Systems
Must-know: The computational model differs from classic input-process-output in two directions: heterogeneous input (many uncontrolled sources) and diverse output (enriched events to different clients in different formats). Producers, consumers, and processing are decoupled.
⚠️ Top pitfall: Assuming the system controls its sources (it does not) or that consumption must happen immediately after processing (it does not).
Self-check: What is an enriched event?
Connects to: 3.2, 3.4 (other concepts in this lecture).
Streaming Systems versus Real-Time Systems
Must-know: There is no streaming in hard real-time systems: hard real-time is a real-time system, not a streaming system. The life-risk check separates them — no streaming system waits on something with potential loss of life.
⚠️ Top pitfall: Calling any continuous data flow 'streaming' — self-driving cars process continuous frames but are hard real-time, which is not a streaming system.
Self-check: Can a streaming data system exist inside a hard real-time system?
Connects to: 3.1, 3.5 (other concepts in this lecture).
Complex Event Processing
Must-know: Decision based on the enriched event → hard real-time; analytics-only enrichment → not hard real-time. CEP classifies as soft real-time (seconds-to-milliseconds, no life risk).
⚠️ Top pitfall: Classifying CEP as near real-time because the correlated events are minutes apart — the processing itself must finish in seconds or the insight dies.
Self-check: In the CCTV example, what inference does combining the two frame sets produce?
Connects to: 3.1, 3.6 (other concepts in this lecture).
The Train Tracking Case Study
Must-know: Train tracking is soft real-time: the signal must reach the train quickly enough for a big machine to react, so it cannot be minutes. Driver-controlled = soft; purely autonomous (driverless, CBTC) = hard. Life risk alone does not make it hard — the existing railway infrastructure handles collision safety, the stream system only monitors.
⚠️ Top pitfall: Classifying by the tolerance of the data (a 5-minute-old position is fine) instead of the tolerance of the decision path (a 5-minute-old routing signal is dangerous).
Self-check: Why is train tracking soft real-time even though a collision risks life?
Connects to: 3.5, 3.1 (other concepts in this lecture).
Batch Processing
Must-know: Batch is always a scheduled activity over accumulated events; triggers can be time-based (stopwatch) or count-based (water level — the 'special window'). Payroll is batch whether daily or monthly.
⚠️ Top pitfall: Answering 'batch is always time-based' — the count-of-events trigger is the professor's explicitly confirmed special window.
Self-check: What are the two ways to decide what goes into a batch?
Connects to: 3.8, 3.10 (other concepts in this lecture).
Batch versus Stream Processing: Four Differentiators
Must-know: Four differentiators: data scope, data size, time scale/latency, depth of analysis (batch = complex/comprehensive; stream = event enrichment only). Batch needs auxiliary storage; stream processes as it arrives. The rolling window covers everything eventually, but each analysis covers a tiny fraction.
⚠️ Top pitfall: Arguing the rolling window 'misses data' — it does not skip messages permanently; the point is the tiny fraction of data considered in each current analysis.
Self-check: Name the four differentiators between batch and stream processing.
Connects to: 3.7, 3.9 (other concepts in this lecture).
Processing Frameworks
Must-know: Storm (tuple-at-a-time), Spark Streaming (micro-batch), Kafka (durable distributed log decoupling producers and consumers). Evaluate any framework on the four differentiators of 3.8.
⚠️ Top pitfall: Listing Spark/Storm as pure streaming rather than micro-batch — the lecture explicitly places them on the micro-batch end of the spectrum.
Self-check: Why is Spark Streaming called a micro-batch framework?
Connects to: 3.8, 3.11 (other concepts in this lecture).
Why Stream Processing: Four Reasons
Must-know: Four reasons: nature of data (never-ending stream, collective intelligence), time series data (p = f(t) — value is a function of every tick), storage/infrastructure limits (process what passes, accept approximate insight), and the data source (IoT/monitoring systems emit per-event questions).
⚠️ Top pitfall: Listing only one or two reasons in an answer; the professor counts exactly four, so enumerate all four.
Self-check: What makes the stock market the classic example of time series data?
Connects to: 3.2, 3.11 (other concepts in this lecture).
Streaming Data: Sources and Use Cases
Must-know: Sources: smart devices, IoT devices, mobile phones. Use cases: financial institutions (time series), transportation sensors, defect identification, Twitter sentiment, flight tracking, ATM transactions, train geolocation — each traceable to a reason from 3.10.
⚠️ Top pitfall: Treating use cases as a memorized list instead of mapping each to its driving reason from section 3.10.
Self-check: Name three streaming data sources and two use cases from class.
Connects to: 3.10, 3.6 (other concepts in this lecture).
Exam Guidance Summary
Must-know: Classification question format: latency scale + tolerance + life-risk check, then the class; always refer to the latency-tolerance table; enriched-event decision rule; two operations; four differentiators; four reasons.
⚠️ Top pitfall: Answering classification questions with intuition instead of the two axes.
Self-check: Which book is the course reference for this material?
Connects to: 3.1, 3.5, 3.8, 3.10 (other concepts in this lecture).
Key Industry Applications
Must-know: Each application maps to a lecture concept: credit card alerts (soft real-time, 24-h settlement), self-driving (hard), CCTV CEP (correlation), payroll (scheduled batch), Storm/Spark/Kafka (platforms).
⚠️ Top pitfall: Quoting applications without the classification or concept that explains them.
Self-check: Which industry application corresponds to complex event processing?
Connects to: 3.1, 3.5, 3.6, 3.7, 3.9 (other concepts in this lecture).
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.