IoT Edge Aggregation & Telemetry
In industrial environments, smart homes, and edge computing scenarios, hardware resources are heavily constrained. Running a full Java Virtual Machine for Kafka or the Erlang runtime for RabbitMQ on a Raspberry Pi or an industrial IPC (Industrial PC) is often overkill and wastes valuable memory.
This is where TinyMQ's 13MB static binary shines.
The Challenge
You have dozens of local sensors (temperature, humidity, motion, RFID) publishing telemetry data via MQTT. You need a local broker to:
- Aggregate the local traffic.
- Provide a buffer if the upstream internet connection drops.
- Securely forward the data to a centralized cloud application via HTTP REST.
The TinyMQ Solution
Deploy TinyMQ on the edge device using the Docker scratch image.
- Ingestion: TinyMQ's built-in MQTT v3.1.1 Gateway listens on port
1883and accepts connections from all local sensors. - Buffering: The Write-Ahead Log (WAL) persists messages to the SD card. If the edge device loses its 4G/Wi-Fi connection, TinyMQ continues to ingest messages up to the
TINYMQ_MAX_MESSAGESlimit. - Forwarding: Using TinyMQ's Webhook Subscriptions, the broker is configured to automatically
POSTmessages to your cloud ingestion API.
Edge Configuration Example
Configure TinyMQ with aggressive memory limits to ensure the edge device never runs out of RAM, while relying on the disk for durability:
services:
tinymq-edge:
image: ghcr.io/x-name15/tinymq:latest
restart: always
ports:
- "1883:1883"
environment:
# Enable strict disk sync for durability on power loss
- TINYMQ_FSYNC=true
# Protect RAM: Max 10,000 messages in memory per topic
- TINYMQ_MAX_MESSAGES=10000
# Drop oldest messages if the buffer fills up during a long network outage
- TINYMQ_DEFAULT_POLICY=drop-oldest
volumes:
- ./tinymq-data:/home/tinymq/data
Cloud Forwarding (Webhook)
Use the TinyMQ CLI to register the cloud webhook. The webhook features built-in exponential backoff, meaning it will gracefully handle upstream cloud downtime.
tmq webhook add \
--topic "sensors.*" \
--url "https://api.mycloud.com/ingest" \
--secret "cloud_hmac_secret"
Why it Shines Here
- Zero OS Dependencies: Can run directly on a minimal Alpine Linux or Yocto build.
- Resource Limits: Hard limits on memory usage prevent the broker from causing Out-Of-Memory (OOM) kernel panics on the host.
- Resiliency: Dropping the oldest messages ensures the system recovers gracefully from prolonged outages without operator intervention.