Analytics & ML · Study deck

Edge Processing: Stream Window Contracts

Two edge services can report the same average from different time windows.

Data Dora is your guide for this deck.

edgepatternsprocessing
Data Dora, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: A practical edge design stores smaller per-second buckets in a ring buffer and subtracts expired buckets as the window advances, but that still multiplies memory by the number of sensors and keyed streams.
  • Explain: Worked example: same stream, three answers: Pick by the question: "how many per minute?" is tumbling; "what is the current smoothed rate?" is sliding; "what happened during one burst of activity?" is session.
  • Explain: None of those answers is wrong; each reflects a different operating question and a different amount of state held by the gateway.
iotclass.org

Major section

Edge Stream Window Contracts

A device has produced messy evidence, an analytic step is about to change an alert or control decision, and someone has to explain why the result should be trusted.

  • Edge Processing Patterns compares filter, aggregate, infer, and store-forward designs.
  • Batch analytics runs over a finite dataset that sits still.
  • Intuition: a window is a stopwatch strategy.

Why it matters

Sliding windows cost more: Because events belong to many overlapping windows, sliding windows keep more in-flight state and recompute more often than tumbling ones.

iotclass.org

Major section

Edge Stream Window Contracts (continued)

Those labels prevent a maintainer from comparing incompatible numbers.

  • The three fundamental window types -- tumbling, sliding, and session -- answer different questions, and choosing the wrong one gives numbers that are technically correct but answer a question you did not ask.
  • Same stream, three very different reports.
  • On a constrained gateway, that memory and CPU cost is real.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

Worked example: a cold-chain gateway receives one temperature event every second from each trailer.

  • If operations wants a compliance report, a tumbling one-hour window can produce one non-overlapping min/max/average for each trailer.
  • If dispatch wants early warning that a trailer is warming, a sliding ten-minute window updated every minute gives a fresher trend.
  • The wrong window can make alerts late, double-count events, or merge two separate operating periods.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

None of those answers is wrong; each reflects a different operating question and a different amount of state held by the gateway.

  • If the trailer sleeps between trips, a session window can group each active delivery run and close after a quiet gap.
  • The raw stream is identical in all three cases; the window changes the business question answered by the same events.
  • Percentiles and distinct-counts are harder and often use approximate sketches.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

Choosing the gap is a trade-off between splitting one activity and merging two.

  • A downstream dashboard that says "average temperature" is ambiguous unless it also says whether the value came from a clock-aligned bucket, a rolling lookback, or one activity session.
  • At the edge, where memory is scarce, the practicalities of maintaining windows matter as much as their semantics.
  • Bounded state or it grows: Every open window is memory.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

Worked example: same stream, three answers: Pick by the question: "how many per minute?" is tumbling; "what is the current smoothed rate?" is sliding; "what happened during one burst of activity?" is session.

  • Incremental aggregation: Sums, counts, and averages can be updated incrementally as events arrive and leave a window, avoiding a full recompute.
  • Session gaps need a timeout: A session window cannot close until a gap of inactivity passes, so it holds state until the timeout fires.
  • So window choice is both a semantic and a resource decision.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

Streaming systems must expire and emit windows promptly; a stuck or ever-growing window is a classic cause of edge memory exhaustion.

  • Tumbling is cheapest and cleanest for periodic aggregates; sliding gives smooth, responsive trends at higher cost; session captures natural bursts of activity but must hold state until a quiet gap.
  • On the edge, the right window is the one that answers the question with the least state held open.
  • If the gateway also tracks per-device sessions, each active device keeps its own timeout and partial aggregate.
  • Edge Processing Patterns for the filter, aggregate, infer, and store-forward choices that consume these windows.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

The engineering decision is not just accuracy; it is whether the available memory, CPU, and battery budget can support the state implied by the chosen window.

  • For a 100 Hz vibration stream, a tumbling one-minute average only needs a running sum, a count, and perhaps a min/max pair for the current minute.
  • A sliding ten-minute window with a one-second slide covers 600 seconds of recent data, so a naive design can drift toward 60,000 retained samples per sensor.
  • Those operational details are easy to hide in code, but they decide whether edge results are repeatable during outages.
iotclass.org

Major section

Edge Stream Window Contracts (continued)

Edge Patterns Placement and Cost Contracts for deciding where windowed processing should run.

  • A practical edge design stores smaller per-second buckets in a ring buffer and subtracts expired buckets as the window advances, but that still multiplies memory by the number of sensors and keyed streams.
  • Late events need a cutoff rule, clock drift needs a timestamp policy, and reboot recovery needs a decision about whether partial windows are replayed, discarded, or emitted with a quality flag.
  • Sliding windows cost more: Because events belong to many overlapping windows, sliding windows keep more in-flight state and recompute more often than tumbling ones.
iotclass.org

Deck summary

Key takeaways

A device has produced messy evidence, an analytic step is about to change an alert or control decision, and someone has to explain why the result should be trusted.

  • Those labels prevent a maintainer from comparing incompatible numbers.
  • Worked example: a cold-chain gateway receives one temperature event every second from each trailer.
  • None of those answers is wrong; each reflects a different operating question and a different amount of state held by the gateway.
  • Choosing the gap is a trade-off between splitting one activity and merging two.
iotclass.org

Retrieval practice

Recall check 1 of 5

Data Dora says: answer from memory, then check your reasoning.

Q1Why does streaming analytics compute over windows rather than the whole stream at once?

AA stream is unbounded and never ends
BBecause streams contain no useful data between windows.
CWindows encrypt the stream.
DBecause hardware cannot process more than one event.
Show answer

Answer: A Windows make an infinite stream tractable by defining finite scopes for computation.

iotclass.org

Retrieval practice

Recall check 2 of 5

Data Dora says: answer from memory, then check your reasoning.

Q2You need a non-overlapping count of events for each clock minute, with every event counted exactly once. Which window type fits?

AA tumbling window of 1 minute: fixed size, contiguous, non-overlapping
BA sliding window, to keep a continuously refreshed count across minute boundaries.
CA session window keyed on inactivity gaps.
DNo window can count events exactly once.
Show answer

Answer: A Tumbling windows partition the stream so each event is counted once.

iotclass.org

Retrieval practice

Recall check 3 of 5

Data Dora says: answer from memory, then check your reasoning.

Q3On a memory-constrained gateway, why can a 10-minute sliding window that advances every 10 seconds be expensive?

AIts heavy overlap means each event belongs to many concurrent windows
BSliding windows never terminate, so they use infinite memory by design.
CSliding windows cannot compute averages.
DOverlap makes the results encrypted and unreadable.
Show answer

Answer: A Fine-grained overlap multiplies open windows and state, which is costly on constrained hardware.

iotclass.org

Retrieval practice

Recall check 4 of 5

Data Dora says: answer from memory, then check your reasoning.

Q4A smart greenhouse has 200 humidity sensors, each sending a reading every second. The greenhouse only needs to know when humidity drops below 40% or rises above 80%. Which edge processing pattern should the gateway use to minimize bandwidth?

AAggregate pattern: compute hourly averages and send summaries
BFilter pattern: only transmit readings that cross the 40% or 80% thresholds
CInfer pattern: run a machine learning model to predict future humidity
DStore-Forward pattern: buffer all readings and upload once per day
Show answer

Answer: B The Filter pattern is ideal when only exceptions (threshold violations) matter.

iotclass.org

Retrieval practice

Recall check 5 of 5

Data Dora says: answer from memory, then check your reasoning.

Q5A fleet of delivery trucks uses satellite connectivity that costs $5 per MB and is available only 30% of the time. Each truck has GPS, temperature, and vibration sensors generating 500 KB per hour. Which edge processing pattern combination is most appropriate?

AFilter only: send GPS changes above 10 km/h and discard temperature and vibration trends whenever the satellite link is down
BInfer only: run anomaly detection on the truck and send alerts, with no local summary buffer for routine sensor history
CStore-Forward combined with Aggregate: buffer data locally, aggregate hourly, and upload summaries when connectivity is available
DNo edge processing: upload raw GPS, temperature, and vibration records whenever the satellite link happens to be available
Show answer

Answer: C With expensive, intermittent satellite connectivity, the best approach combines Store-Forward (buffer during the 70% offline time) with Aggregate (reduce 500 KB/hour to small summaries) to minimize both data loss and satellite costs.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. A · Windows make an infinite stream tractable by defining finite scopes for computation.
  2. A · Tumbling windows partition the stream so each event is counted once.
  3. A · Fine-grained overlap multiplies open windows and state, which is costly on constrained hardware.
  4. B · The Filter pattern is ideal when only exceptions (threshold violations) matter.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. C · With expensive, intermittent satellite connectivity, the best approach combines Store-Forward (buffer during the 70% offline time) with Aggregate (reduce 500 KB/hour to small summaries) to minimize both data loss and satellite costs.
iotclass.org