Topic 217 / Specialist
IoT and device architecture
Chapter 13.9 · IoT and Device Architecture
What and why
Time-series databases (→ 78) ingest and query data indexed by time efficiently; IoT systems are the dominant producer of that kind of data at the extreme end — large numbers of constrained devices continuously reporting sensor readings. But ingestion alone doesn't address the problems of the devices themselves: establishing which device is which, talking to devices too constrained for ordinary HTTP, handling connections that come and go, and knowing a device's last-known state when it isn't currently connected. Builds on: → 78 (time-series databases).
Diagram
Device ◄──MQTT (constrained protocol)──► Broker ──► Device shadow/twin store
└──► Time-series DB (→78)
Fleet firmware service ──staged, resumable update──► Device
How it works
- Device identity and provisioning: each device is issued a unique, verifiable identity at manufacture or first boot, used to authenticate every subsequent connection — without this, the ingestion pipeline can't trust or attribute incoming data.
- Constrained protocols: devices with limited power, memory, and bandwidth use lightweight publish/subscribe protocols (MQTT as the common example) instead of full HTTP, because the overhead and connection model better fit infrequent, small messages over unreliable networks.
- Intermittent connectivity: devices disconnect and reconnect routinely (power loss, weak signal, sleep cycles to save battery); the architecture must treat absence as normal, not an error, and must know what to do with commands generated while a device was offline.
- Device twins / shadow state: a server-side record of a device's last-known and desired state, readable and writable even while the device is offline — commands are queued against the shadow and delivered the next time the device connects, instead of requiring the device to be reachable synchronously.
- Fleet firmware updates: pushing new firmware to thousands or millions of devices must be staged (a small cohort first), resumable (a device that loses power mid-update must not be bricked), and verifiable (checksum or signature) — a failed update at this scale is far more expensive to recover from than a server-side deployment.
- Time-series ingestion (→ 78): sensor readings are naturally time-indexed and high-volume per device; backend storage reuses the time-series database pattern directly, often after passing through the message broker from step 2.
Practical example
(illustrative). A fleet of 10,000 temperature sensors, each publishing a reading every 60 seconds over MQTT, produces roughly 10,000 × (86,400 ÷ 60) = 14,400,000 readings per day. A device offline for an hour simply resumes publishing on reconnect; its shadow still reports its last known reading and an "offline" status for that hour, rather than the system having no record at all.
When to use it
- Use when: designing systems with physically distributed, resource-constrained devices reporting data or needing remote commands over unreliable networks.
- Avoid when: "devices" are actually always-on, unconstrained machines with reliable networking — ordinary API and queue patterns already taught apply without needing device-specific identity, shadow state, or constrained protocols.
- Failure scenarios: a device identity scheme weak enough that a compromised device can impersonate others; a firmware update that bricks a cohort of devices with no rollback path; a device shadow that drifts from real device state because updates aren't acknowledged reliably.
- Simpler alternative: a scheduled HTTP check-in for devices with reliable power and network, skipping persistent-connection brokers and shadow state entirely, when fleet size and constraints don't demand them.
Practice
(Process kind — design exercise; 20–30 min, no lab services). Design the device-shadow update flow for a single device: write out, step by step, what happens when (a) the device reports a new reading while online, (b) a command is sent while the device is offline, and (c) the device reconnects after being offline for an hour. Done when your flow correctly delivers the queued command on reconnect and updates the shadow's "last seen" state in both cases.
Key takeaway
IoT architecture is identity, a constrained protocol, and shadow state working together to make intermittent connectivity a normal condition instead of an error. Done when you can: trace a command through offline queuing to delivery on reconnect. Used next in: nowhere else in this book — a specialization for teams building device fleets directly.
References
None — this topic makes no external claims.
Source directory