2026-11-19

Feeding 100,000 MQTT messages a second to an LLM buys tokens full of noise - build the semantic funnel first

MQTTIoT ArchitectureLLMEdge ComputingTelemetryStream ProcessingData CleaningAI Agents
Feeding 100,000 MQTT messages a second to an LLM buys tokens full of noise - build the semantic funnel first

The pitch writes itself: point a large model at the plant's MQTT stream and let it work out what is wrong. Then the bill arrives. A single motor on a normal day produces temperature, current and speed readings every second, and for ten hours those readings are the same number repeated. Pushing 100,000 messages per second of that into a model is not analysis, it is buying tokens to read the word "normal" a few million times.

It is worse than expensive. A wall of stationary white noise does not just dilute the model's attention, it actively degrades judgement: the one anomalous window is a rounding error against hours of steady state. The scarce resource in IoT-plus-AI is not compute and it is not tokens. It is architectural restraint.

What the model needs is abnormal semantics, not raw points

Consider how a person works. Sitting in a room, you do not consciously sample the temperature every ten milliseconds. Your nervous system suppresses steady state entirely until cold air arrives and the temperature drops, and only then does the thinking start: is a window open?

The system should be built the same way, in three layers.

The output is not a stream of numbers. It is a sentence like "three over-temperature events in the last ten seconds, peak 94 °C, cooling fan current zero" — which is the thing an agent can actually reason about, and which costs a few hundred tokens instead of a few hundred thousand.

Do not build an aircraft carrier to run a filter

The failure mode on the other side is just as common. Say "sliding window, deadband, consecutive-state logic" in a planning meeting and someone will reach for Kafka, Flink and Redis. For a data warehouse ingesting hundreds of billions of records a day, that stack is irreplaceable. For a vertical IoT team, or a private deployment on a factory edge gateway, maintaining a distributed JVM stream-processing cluster in order to remove noise before an AI call is a running cost larger than the business it serves.

Architecture should match the weight of the problem. Inside the MQTT ecosystem there are thinner shapes that do the same job. Apache BifroMQ's Tenon pipeline, for example, uses a Source → Lua → Sink model in which the processing unit is split into independent channels, each handling its messages and timers serially with its own in-memory state. No external state store, no distributed locks: a very thin scripted state machine can do both jobs as the data flows past — discard anything inside the deadband, and watch the consecutive-violation count or the slope.

That is enough to keep 99% of the waste outside the model, and to let the remaining 1% arrive carrying its own compression: "three consecutive over-temperature readings in ten seconds" instead of ten thousand samples of 24.1 °C.

What changes downstream

Once the funnel exists, the character of the whole system changes. The upstream sensor layer keeps sampling at full rate, so nothing is missed at the moment that matters. The downstream model stops receiving tens of millions of lines of repeated JSON, token cost falls by one to two orders of magnitude, and — this is the counter-intuitive part — both latency and accuracy improve, because the model is no longer being asked to find a signal inside its own input noise.

The same logic applies to the choice of where to put the cleaning. Deadband filtering is arithmetic on the last value; a state machine over a ten-second window is a counter and a timer. Neither needs a query engine. Putting them in a Lua hook next to the broker costs microseconds and no new infrastructure; putting them in a separate Flink job costs a cluster, a schema registry, and a team to run it.

The question the funnel does not answer

Flow control and cleaning are now solved cheaply. What remains is the architectural boundary that is easy to get wrong: where should the cleaning, the inference and the model connection actually live?

It is tempting to put them inside the MQTT broker's own process, because that is where the messages already are and the latency is lowest. That temptation is the subject of the next piece in this series, and the argument against it is not about performance. It is about what happens to a broker when the code running inside it blocks, allocates, or crashes.

← All news