Where AI Models Actually Belong in an IoT Telemetry Pipeline
Most IoT machine learning projects do not fail because the model is bad. They fail because the model lives in the wrong place. I have seen a 40 KB gradient-boosted model shipped to a cloud GPU cluster, adding 800 ms of round-trip latency to a vibration alarm that needs to fire in under 50 ms. I hav

Most IoT machine learning projects do not fail because the model is bad. They fail because the model lives in the wrong place.
I have seen a 40 KB gradient-boosted model shipped to a cloud GPU cluster, adding 800 ms of round-trip latency to a vibration alarm that needs to fire in under 50 ms. I have also seen a 90 MB transformer stuffed onto a Cortex-M4 gateway with 256 MB of RAM, where it ran at 0.4 inferences per second and starved the MQTT broker. Both teams had decent models. Both systems were unusable.
This article is about placement: deciding which inference runs on the device, which runs on the gateway, and which deserves the cloud. It is the first post in a ten-part series on AI models for IoT data analysis and alerting, and later posts go deep on edge runtimes, feature pipelines, anomaly detection, rule engines, alert de-duplication, safe rollout, and LLM-assisted triage.
A modern telemetry architecture has three natural execution tiers. They differ in a way that matters far more than raw compute: what they can see.
The device sees a single signal at high rate but almost no context. The cloud sees enormous context but pays a network round trip for every observation. The gateway sits in the sweet spot: enough history to judge "is this normal for this machine right now", and enough locality to act in milliseconds.
The placement error is almost always one of these two:
A single vibration sensor sampling at 3.2 kHz, 16-bit, three axes produces roughly:
3,200 samples/s × 3 axes × 2 bytes = 19,200 B/s ≈ 19.2 KB/s per sensor Enter fullscreen mode Exit fullscreen mode That is only 154 kbit/s, which sounds survivable — until you multiply by 2,000 sensors across a plant and by the fact that many industrial sites still run on a shared 4G link with metered data.
2,000 sensors × 19.2 KB/s = 38.4 MB/s = 307 Mbit/s of raw telemetry Enter fullscreen mode Exit fullscreen mode Now the same fleet after edge feature extraction. Each sensor emits one 48-byte feature vector every 10 seconds:
2,000 × 48 B / 10 s = 9.6 KB/s ≈ 77 kbit/s Enter fullscreen mode Exit fullscreen mode That is a 4,000× reduction, and it is the single strongest argument for edge processing. But note what you lose: the raw waveform. If the alarm fires, somebody will want the raw data for diagnosis, so the pipeline still needs a ring buffer on the device that uploads the last N seconds when an alarm triggers. Extract features continuously, retain raw data conditionally.
Rather than debating philosophy, run each candidate model through four questions:
1. What is the deadline? Work backward from the consequence, not the model.
2. How much history does the decision need?
A single-sample threshold needs zero history. A "vibration is 3σ above the 30-minute baseline" decision needs 30 minutes of context — and if the device only keeps a 2-second buffer, that decision simply cannot live there. Count the samples the decision requires, multiply by bytes per sample, and compare against the RAM you actually have after the RTOS and the network stack.
3. How often does the decision logic need to change?
This is the most underrated axis. A model that must be retrained monthly belongs where you can ship updates monthly without a truck roll. If your fleet is 5,000 devices behind NAT on cellular, updating a device model is a project; updating a gateway container is a deploy. Put fast-moving logic at the tier with the cheapest update path, and freeze only the logic that genuinely must be frozen.
4. What does a false positive cost at each tier?
A local alarm that pages a technician at 3 a.m. is expensive. A cloud alarm that pages the same technician is equally expensive but arrives with better context. If your false-positive rate is still above ~5%, the reasoning probably belongs one tier up, where you can join more signals before you wake someone.
Here is the shape I use for a gateway-side placement policy. It is deliberately boring: a lookup table plus explicit budgets, so that when a colleague adds a model, the constraints are visible in review rather than discovered in production.
from dataclasses import dataclass @dataclass ( frozen = True ) class Tier: name: str max_latency_ms: int max_model_kb: int history_s: int update_cadence: str TIERS = { "device": Tier ( "device", max_latency_ms = 50, max_model_kb = 256, history_s = 2, update_cadence = "quarterly" ), "gateway": Tier ( "gateway", max_latency_ms = 1000, max_model_kb = 8192, history_s = 3600, update_cadence = "weekly" ), "cloud": Tier ( "cloud", max_latency_ms = 60000, max_model_kb = 1_000_000, history_s = 31_536_000, update_cadence = "daily" ), } @dataclass ( frozen = True ) class ModelSpec: name: str latency_ms: int size_kb: int history_s: int needs_raw_waveform: bool def fits ( spec: ModelSpec, tier: Tier ) -> bool: return ( spec. latency_ms <= tier. max_latency_ms and spec. size_kb <= tier. max_model_kb and spec. history_s <= tier. history_s and not ( spec. needs_raw_waveform and tier. name == "cloud" ) ) def place ( spec: ModelSpec ) -> str | None: for name in ( "device", "gateway", "cloud" ): # cheapest tier first if fits ( spec, TIERS [ name ] ): return name return None # needs a redesign, not a bigger tier Enter fullscreen mode Exit fullscreen mode Two things make this useful in practice. First, place() searches from the cheapest tier upward, which keeps cloud costs honest. Second, "cheapest tier first" only works because the tiers are ordered by capability, not by cost — the device is cheapest to run and the most constrained, so anything that fits there is also cheap to operate.
Note the needs_raw_waveform clause. It encodes the constraint that most teams learn the hard way: once you have discarded the raw signal, cloud-side models can only reason over features, and some failure modes (transient spikes, mechanical impulses, clipping) are invisible in 10-second aggregates.
Placement questions get much easier once you accept that detection and explanation have different requirements.
Detection wants to be close to the data and cheap. Explanation wants context and compute. So split them:
sensor → [device: hard limits + feature extraction] → [gateway: windowed anomaly model + rule engine] → (MQTT, only on state change) → [cloud: correlation, dedup, triage, notification] Enter fullscreen mode Exit fullscreen mode The gateway publishes on state transitions, not on every sample. A machine that is "normal" for six hours produces one message, not 21,600. The cloud receives a stream of events it can actually reason about, and the device keeps a ring buffer so the raw waveform can follow the event if anyone asks.
This structure also gives you a natural safety story. Hard limits (over-temperature, over-pressure, vibration above mechanical tolerance) live on the device in deterministic code, not in a model. A model can be wrong; a limit switch is auditable. Never put a learned model in the path of a hard safety interlock — put it in the path of maintenance decisions, where being wrong costs money instead of limbs.
Over the next posts I will build the pieces this architecture implies, in the order you would actually need them:
If you are starting a project, the single most valuable thing you can do this week is write down, per decision, the deadline, the history required, the update cadence, and the cost of a false positive. Most placement arguments dissolve the moment those four numbers are on the same page.
Next in the series: Edge Inference for Sensor Data — Choosing a Runtime and Shrinking the Model.