MQTT
A compact publish-subscribe protocol built for intermittent networks, constrained devices, hierarchical topics, and broker-pushed delivery.
Best for device-to-cloud and command-and-control messaging.
Protocol comparison
MQTT connects constrained clients through a lightweight broker. Kafka stores ordered event streams for high-throughput processing and replay. Many IoT systems need MQTT at the edge and Kafka behind the ingestion boundary.
The protocols solve different boundaries. MQTT optimizes the device connection; Kafka optimizes the durable processing backbone.
MQTT
A compact publish-subscribe protocol built for intermittent networks, constrained devices, hierarchical topics, and broker-pushed delivery.
Best for device-to-cloud and command-and-control messaging.
Apache Kafka
A distributed event log built for durable retention, partitioned throughput, consumer-controlled offsets, replay, and stream processing.
Best for service-to-service event pipelines, analytics, and replay.
| Capability | MQTT | Kafka |
|---|---|---|
| Core model | Brokered publish-subscribe with hierarchical topics | Partitioned append-only log with consumer offsets |
| Typical clients | Sensors, embedded devices, gateways, mobile clients | Backend services, connectors, stream processors |
| Delivery | Broker pushes matching messages; QoS 0, 1, or 2 | Consumers pull and commit offsets per consumer group |
| Retention and replay | Retained latest value and session queues; not a general event archive | Time- or size-based durable retention with offset replay |
| Routing | Hierarchical topic filters with + and # wildcards | Flat topics and partitions; routing belongs in producers or processors |
| Network assumptions | Designed for low bandwidth, high latency, and reconnecting clients | Designed for stable data-center or cloud service connectivity |
A single system can use both without duplicating their responsibilities.
Keep protocol responsibilities explicit so replay, backpressure, and authorization remain understandable.
Kafka is not a drop-in device broker. It does not provide MQTT sessions, QoS flows, retained messages, hierarchical topic filters, or the same constrained-client footprint.
MQTT can queue session messages and retain a latest value, but it is not designed as a long-lived replayable event log for many independent backend consumers.
Run it at a controlled ingestion boundary where credentials, schemas, retry behavior, partition keys, and dead-letter handling can be operated and observed.
Compare the browser transport question, then return to MQTT implementation and security.