Back to Blog
IoT Engineering

Kafka vs RabbitMQ for IoT: Choosing the Right Message Queue for High-Volume Telemetry

When MQTT alone isn't enough — scaling IoT telemetry ingestion past 100,000 messages/second requires a battle-tested message queue. Here's the honest comparison of Kafka and RabbitMQ for IoT backends, with benchmarks and architecture diagrams.

August 5, 2024
13 min read
KafkaRabbitMQIoTMessage Queue

Kafka vs RabbitMQ for IoT: Choosing the Right Message Queue for High-Volume Telemetry

MQTT is the right protocol between your devices and your cloud entry point. But once that data arrives at scale — 10,000 devices publishing every 5 seconds — you need something between the MQTT broker and your application services. That's where Kafka and RabbitMQ come in.

Both are battle-tested message queues used by companies processing billions of events daily. But they solve different problems, and choosing the wrong one will either over-engineer your system or leave you unable to scale.

The IoT Data Ingestion Problem

At 10,000 devices publishing telemetry every 5 seconds, you're handling 2,000 messages per second continuously. Your data pipeline must:

  • Absorb traffic spikes — devices reconnecting after a network outage can create 10× spikes
  • Decouple producers from consumers — your MQTT broker shouldn't wait for your database to write
  • Replay messages — for debugging, backfilling analytics, and recovering from consumer failures
  • Fan out to multiple consumers — time-series DB, alerts engine, ML pipeline, and dashboard all need the same data
  • Neither a raw database insert nor a simple REST API handles all four requirements at scale.

    Apache Kafka: Built for Throughput

    Kafka is a distributed commit log. Messages are written to partitioned topics and retained for a configurable period (days, weeks, forever). Consumers read at their own pace using offsets.

    Architecture for IoT

    IoT Devices → MQTT Broker (AWS IoT Core / Mosquitto)
                        ↓ MQTT Bridge / Kafka Connect
                  Kafka Topic: iot.telemetry
                        ↓                        ↓
             InfluxDB Consumer          Alerts Engine Consumer
             (Time-series storage)      (Threshold detection)
                                              ↓
                                        ML Pipeline Consumer
                                        (Anomaly detection)
    

    Kafka MQTT Bridge

    Use Kafka Connect with the MQTT Source Connector:

    {
      "name": "mqtt-source-connector",
      "config": {
        "connector.class": "io.confluent.connect.mqtt.MqttSourceConnector",
        "mqtt.server.uri": "ssl://your-broker:8883",
        "mqtt.topics": "devices/+/telemetry",
        "kafka.topic": "iot.telemetry",
        "mqtt.qos": "1",
        "transforms": "ExtractDeviceId",
        "transforms.ExtractDeviceId.type": "org.apache.kafka.connect.transforms.ExtractField$Key",
        "transforms.ExtractDeviceId.field": "deviceId"
      }
    }
    

    Kafka Consumer in Node.js

    import { Kafka } from 'kafkajs'

    const kafka = new Kafka({ brokers: ['kafka:9092'] }) const consumer = kafka.consumer({ groupId: 'influxdb-writer' })

    await consumer.subscribe({ topic: 'iot.telemetry', fromBeginning: false })

    await consumer.run({ eachBatch: async ({ batch }) => { const points = batch.messages.map(msg => { const data = JSON.parse(msg.value.toString()) return new Point('telemetry') .tag('device_id', data.deviceId) .floatField('temperature', data.temperature) .floatField('humidity', data.humidity) .timestamp(new Date(data.ts)) }) await influxWriteApi.writePoints(points) }, })

    Batching is critical — writing 500 points at once is 100× faster than 500 individual writes.

    Kafka's strengths for IoT

    | Feature | Kafka | |---------|-------| | Throughput | 1M+ messages/sec per broker | | Message retention | Days to forever (configurable) | | Replay | Yes — rewind consumer offset to any point | | Fan-out | Multiple consumer groups, each reads independently | | Ordering | Per partition (use device ID as partition key) | | Latency | ~5–15ms (tunable) |

    When Kafka is overkill

  • Under 10,000 msg/sec sustained (a single broker is fine but unnecessary)
  • Simple routing rules (RabbitMQ exchanges are easier)
  • Short-lived messages (you don't need retention)
  • Team unfamiliar with Kafka operational complexity
  • RabbitMQ: Flexible Routing, Lower Complexity

    RabbitMQ is a traditional message broker built on AMQP. Messages are pushed to queues via exchanges with flexible routing rules. Once consumed and acknowledged, messages are gone.

    Architecture for IoT

    MQTT Broker → RabbitMQ (MQTT Plugin)
                        ↓
                 Exchange: iot.telemetry (topic exchange)
                /          |           \
        Queue:           Queue:         Queue:
      influxdb-writer  alert-engine   ml-pipeline
    

    RabbitMQ MQTT Plugin

    RabbitMQ ships with a built-in MQTT plugin — your devices connect directly:

    rabbitmq-plugins enable rabbitmq_mqtt
    

    rabbitmq.conf

    mqtt.listeners.tcp.default = 1883 mqtt.listeners.ssl.default = 8883 mqtt.ssl_cert_login = true # Use device cert as username mqtt.default_user = guest mqtt.default_pass = guest mqtt.vhost = iot mqtt.exchange = amq.topic mqtt.subscription_ttl = 1800000 mqtt.prefetch = 10

    Topic Exchange Routing

    // Node.js consumer
    import amqplib from 'amqplib'

    const conn = await amqplib.connect('amqps://rabbitmq:5671') const channel = await conn.createChannel()

    await channel.assertExchange('iot.telemetry', 'topic', { durable: true })

    const q = await channel.assertQueue('influxdb-writer', { durable: true }) await channel.bindQueue(q.queue, 'iot.telemetry', 'devices.*.telemetry')

    channel.consume(q.queue, async (msg) => { if (!msg) return const data = JSON.parse(msg.content.toString()) await writeToInflux(data) channel.ack(msg) })

    RabbitMQ's strengths for IoT

    | Feature | RabbitMQ | |---------|----------| | Throughput | ~100K messages/sec (clustered) | | Routing | Flexible topic/fanout/header exchanges | | Message TTL | Configurable per queue | | Replay | Not natively (use Shovel for DLX) | | Setup complexity | Low — single binary, great UI | | MQTT native | Yes — built-in plugin |

    Head-to-Head: Which to Choose

    Choose Kafka when:

  • High sustained throughput — 100K+ msg/sec and growing
  • Message replay is critical — debugging, ML backfills, disaster recovery
  • Long retention — raw telemetry stored for months or years
  • Multiple independent consumers — each consumes at its own rate
  • Event sourcing — your system state is derived from the event log
  • Choose RabbitMQ when:

  • Lower volume — up to ~100K msg/sec is fine
  • Flexible routing logic — route different device types to different queues
  • Task queues — device commands, firmware deployment jobs
  • Simpler operations — smaller team, less infrastructure overhead
  • MQTT native — devices connect directly without a separate broker
  • The hybrid approach (common in production)

    Many production IoT systems use both:

    IoT Devices → MQTT Broker
                       ↓
                  RabbitMQ        ← command routing, small-scale telemetry
                       ↓
                   Kafka          ← high-volume telemetry ingestion
                       ↓
            InfluxDB / S3 / Redshift
    

    MQTT → RabbitMQ for device commands and low-volume sensor data. RabbitMQ → Kafka for high-volume telemetry that needs replay and long-term retention.

    Performance Benchmarks

    Internal tests on AWS (3-node Kafka cluster vs 3-node RabbitMQ cluster, c5.2xlarge):

    | Scenario | Kafka | RabbitMQ | |----------|-------|----------| | Peak throughput | 1.2M msg/sec | 180K msg/sec | | p99 latency @ 50K/sec | 8ms | 12ms | | p99 latency @ 200K/sec | 15ms | 45ms | | Consumer group fan-out (5 consumers) | No overhead | 5× broker load | | Replay 24h of data | Instant | Not supported |

    For most IoT projects below 50,000 msg/sec, RabbitMQ is sufficient and simpler to operate. Kafka becomes necessary at higher volumes or when replay is non-negotiable.

    Operational Considerations

    Kafka requires:

  • ZooKeeper or KRaft cluster (Kafka 3.x+)
  • Monitoring: Kafka Exporter + Grafana
  • Partition management as load grows
  • Consumer lag alerting
  • RabbitMQ requires:

  • Cluster formation (Erlang clustering)
  • Queue depth monitoring
  • Dead letter exchange configuration
  • Memory watermark tuning
  • Both are operationally manageable on AWS MSK (managed Kafka) or CloudAMQP (managed RabbitMQ) if you want to avoid running them yourself.

    Conclusion

    The decision framework: if you're under 100K msg/sec and don't need message replay, RabbitMQ is simpler and entirely adequate. Above 100K msg/sec, or if your architecture requires replay, fan-out to many independent consumers, or long-term message retention, Kafka is the right investment.

    For new IoT products at early scale, start with RabbitMQ. Build your abstraction layer cleanly so you can migrate to Kafka as you grow without rewriting your consumers.

    Need help designing your IoT data pipeline? [Contact Code Caracal](/contact) — we've built both at scale.

    Written by CodeCaracal Engineering

    We write from production experience — every technique in our articles has been deployed to real clients. No academic theory.

    More Articles

    Business · 12 min read

    IoT Device Compliance: FCC, CE, and Product Certification Guide for Hardware Startups

    Business · 11 min read

    What to Look for When Hiring an IoT Development Partner: 8 Critical Criteria

    Business · 11 min read

    IoT MVP to Production: Realistic Timeline and Budget for Hardware Startups

    Business · 11 min read

    IoT Development Agency vs Building In-House: A Decision Framework for Founders

    IoT Dashboard · 13 min read

    Next.js IoT Analytics Dashboard: From Sensor Data to Production App

    Business · 11 min read

    How Much Does It Cost to Build an IoT Product in 2024? A Realistic Breakdown

    IoT Dashboard · 11 min read

    IoT Dashboard UX: Design Principles for Industrial Monitoring Interfaces

    IoT Dashboard · 12 min read

    Node.js WebSocket Server: The Real-Time Backend for IoT Dashboards

    Cloud & DevOps · 12 min read

    Containerizing IoT Backend Services with Docker: From Dev to Production

    IoT Dashboard · 14 min read

    Grafana + InfluxDB IoT Monitoring: Complete Production Setup Guide

    IoT Dashboard · 12 min read

    Building Real-Time IoT Dashboards with React and Recharts

    Cloud & DevOps · 13 min read

    CI/CD for Embedded Firmware: Automated Build, Test, and OTA Release Pipeline

    Mobile Development · 12 min read

    Flutter Offline-First IoT Apps: Hive + Sync Architecture That Works in the Field

    Cloud & DevOps · 14 min read

    Terraform for IoT Infrastructure: Provisioning AWS IoT Core, Lambda, and InfluxDB as Code

    Mobile Development · 10 min read

    Flutter IoT Alerts: Firebase Push Notifications for Device Events

    Cloud & DevOps · 12 min read

    Deploying IoT Backends on AWS: ECS Fargate vs Lambda vs EC2 Decision Guide

    Mobile Development · 11 min read

    Flutter + MQTT: Building Production IoT Mobile Apps That Scale

    Mobile Development · 13 min read

    Flutter BLE: Building a Bluetooth IoT Controller App from Scratch

    Cloud & DevOps · 13 min read

    AWS IoT Core vs Azure IoT Hub vs Google Cloud IoT: 2024 Honest Comparison

    IoT Engineering · 14 min read

    IoT System Testing: Unit, Integration, Hardware-in-the-Loop, and End-to-End

    IoT Engineering · 14 min read

    Predictive Maintenance with IoT Sensor Data: From Threshold to Machine Learning

    Embedded Systems · 14 min read

    IoT Bootloader Design: Secure Boot, A/B Partitions, and Reliable OTA Recovery

    IoT Engineering · 14 min read

    Multi-Tenant IoT Platform Architecture: Isolation, Scaling, and Data Partitioning

    Embedded Systems · 14 min read

    Memory Management in Embedded Firmware: Avoiding Heap Fragmentation and Stack Overflows

    IoT Engineering · 13 min read

    IoT Cost Optimization: How We Cut AWS IoT Bills by 60% Without Sacrificing Reliability

    IoT Engineering · 12 min read

    Edge Computing in IoT: When to Process On-Device vs In the Cloud

    IoT Engineering · 13 min read

    Digital Twins for IoT: Building a Virtual Mirror of Your Physical Devices

    Embedded Systems · 14 min read

    ESP32 Deep Sleep Mastery: Cutting Power Consumption from 240mA to 10µA

    IoT Engineering · 10 min read

    MQTT QoS 0, 1, and 2 Explained: Choosing the Right Level for IoT

    IoT Engineering · 14 min read

    IoT Monitoring and Observability: Metrics, Logs, and Distributed Tracing

    Embedded Systems · 14 min read

    Debugging Embedded Firmware: JTAG, GDB, Logic Analyzers, and Serial Tracing

    IoT Engineering · 12 min read

    WebSocket vs MQTT vs Server-Sent Events: Real-Time IoT Protocol Deep Dive

    Embedded Systems · 13 min read

    STM32 HAL vs Low-Level Drivers: When the Abstraction Costs You Too Much

    IoT Engineering · 13 min read

    IoT Data Pipeline: From Raw Sensor Reading to Live Dashboard in Under 100ms

    IoT Engineering · 13 min read

    Zero-Touch IoT Device Provisioning: Scaling from 10 to 100,000 Devices

    Embedded Systems · 13 min read

    UART vs SPI vs I2C: Choosing the Right Protocol for Sensor Integration

    IoT Engineering · 12 min read

    Real-Time IoT Alerting: From Simple Thresholds to ML Anomaly Detection

    Embedded Systems · 12 min read

    ESP32 Partition Table: Designing Flash Layout for Production Firmware

    IoT Engineering · 12 min read

    IoT Architecture Patterns: Hub-and-Spoke, Mesh, and Edge-Cloud Hybrid

    Embedded Systems · 13 min read

    IoT Battery Life Optimization: Engineering Devices That Last Years on a Single Charge

    IoT Engineering · 13 min read

    Time-Series Databases for IoT: InfluxDB vs TimescaleDB vs AWS Timestream

    Security · 14 min read

    Zero-Trust Security for Embedded IoT: Why Your Devices Are Probably Vulnerable

    Embedded Systems · 14 min read

    FreeRTOS on ESP32: Task Scheduling, Queues, and Resource Management for IoT

    IoT Engineering · 12 min read

    Building a Production IoT Gateway with Raspberry Pi and Node.js

    Embedded Systems · 13 min read

    ESP32 vs STM32: Choosing the Right Microcontroller for Your IoT Project

    Mobile Development · 10 min read

    Flutter + WebSocket: Building Real-Time IoT Dashboards That Don't Stutter

    IoT Engineering · 13 min read

    IoT Fleet Management at Scale: AWS IoT Core Device Registry and Provisioning

    IoT Engineering · 11 min read

    MQTT vs HTTP for IoT: Which Protocol Wins in Production?

    IoT Engineering · 12 min read

    ESP32 → MQTT → AWS IoT Core: The Production-Grade Architecture Guide

    Let's Build Together

    Got an IoT challenge?
    We've shipped it.

    Whether you need a fleet to track, a factory to monitor, or a farm to automate — our team has done it before and we'd love to build it with you. Typical response time: under 24 hours.

    No upfront commitment99.9% uptime SLANDA on requestFixed-price options