Messaging Systems Compared: Kafka, RabbitMQ, AWS SQS & SNS
A practical comparison of the four messaging systems every backend engineer should know — with three runnable, open-source Next.js apps you can clone to learn Kafka event streaming, RabbitMQ routing, and AWS SQS/SNS pub/sub hands-on.
Kafka Tutorial
Interactive Kafka app built with Next.js and KafkaJS. Create topics, produce messages, consume them, and inspect consumer groups.
View on GitHubRabbitMQ Tutorial
Interactive demos for all five exchange types built with Next.js and amqplib. Fanout, Direct, Topic, Headers, and Dead Letter Queues.
View on GitHubSQS & SNS Tutorial
Full messaging demo with Next.js 16 and AWS SDK v3. Covers SQS queuing and SNS pub/sub patterns with real AWS integration.
View on GitHubIntroduction
Modern distributed systems rely on messaging infrastructure to decouple components, handle asynchronous workloads, and scale reliably. But not all messaging systems are created equal — Apache Kafka, RabbitMQ, AWS SQS, and AWS SNS each solve different problems with fundamentally different architectures.
This post summarizes three hands-on, open-source tutorials — one per system — into a single reference. Each repository is a self-contained Next.js app you can clone and run against a real broker to see the concepts in action. Head to the kafka-tutorial , rabbitmq-tutorial and sqs-sns-tutorial repositories for the full, runnable code and step-by-step README instructions.
Summary Decision Matrix
Before diving into each system, here is a high-level comparison to orient your thinking:
| Feature | Apache Kafka | RabbitMQ | AWS SQS | AWS SNS |
|---|---|---|---|---|
| Primary Use Case | Massive event streaming, log aggregation, event replay | Complex message routing, traditional task queues | Simple serverless task queues, buffering/load-leveling | Broadcasting messages, Fan-out, User notifications |
| Architecture | Distributed Log / Append-only | Message Broker (Exchanges & Queues) | Simple Point-to-Point Queue | Pub/Sub (Push based) |
| Message Retention | Days, weeks, or indefinitely | Deleted immediately after consumption (Ack) | Up to 14 days | No retention (fire-and-forget unless queued) |
| Replayability | ✅ Yes (Native offset resetting) | ❌ No (Once consumed, it's gone) | ❌ No | ❌ No |
| Overhead/Ops | High (Requires KRaft, clustering, tuning) | Medium (Server management, Erlang VM, clustering) | Zero (Fully managed by AWS) | Zero (Fully managed by AWS) |
Apache Kafka — The Event Streamer & Storage
Kafka is a distributed, append-only log built for massive throughput and event replay. The kafka-tutorial repo is an interactive Next.js + KafkaJS app that connects to a live broker running in Docker (KRaft mode, no ZooKeeper needed) and lets you create topics, produce keyed and unkeyed messages, consume them, and inspect consumer groups — all from the browser.
The repo README walks through starting Kafka with a single Docker Compose file, the full set of API routes (/api/topics, /api/produce, /api/consume, /api/consumer-groups), and the project structure — including the ConsumerGroupsPanel that demonstrates partition assignment and rebalancing in real time.
RabbitMQ — The Smart Message Router
RabbitMQ trades Kafka's raw throughput for sophisticated, broker-side routing logic. The rabbitmq-tutorial repo is a Next.js + amqplib app with a dedicated, interactive demo page for each exchange type: Fanout, Direct, Topic, Headers, and Dead Letter Queues.
Each demo follows the same Setup → Publish → Consume workflow so you can watch routing keys, header matching, and TTL-based dead lettering in action, including the x-death metadata RabbitMQ attaches when a message is rejected, expires, or exceeds a queue's max length.
AWS SQS & SNS — The Serverless Messaging Duo
SQS and SNS are AWS's fully-managed, zero-ops answers to queuing and pub/sub. The sqs-sns-tutorial repo is a Next.js 16 + AWS SDK v3 app covering both services: sending, receiving, and long-polling SQS messages, plus publishing SNS notifications across email, SMS, HTTP, and SQS subscription protocols.
The repo demonstrates the classic SNS + SQS fan-out pattern, includes a dedicated AWS_SETUP.md guide for configuring IAM permissions and resources, and ships custom hooks like useSQS for wiring the demo UI to the API routes.
Tech Stack
All three repositories share a consistent stack: Next.js and TypeScript for the app and API routes, with Docker for running local Kafka and RabbitMQ brokers, KafkaJS for Kafka, amqplib for RabbitMQ, and the AWS SDK v3 for SQS and SNS.
Getting Started
Each repository is independent and can be cloned and run on its
own. For Kafka or RabbitMQ, start the broker with the provided
Docker Compose file, then run npm install and npm run dev. For SQS/SNS, follow the AWS_SETUP.md guide to configure your AWS credentials and resources first. See each repository's README for full, step-by-step setup instructions.
Conclusion
Kafka, RabbitMQ, SQS, and SNS are all excellent tools — but they excel in different scenarios. Use Kafka when you need massive throughput, event replay, or long-term event storage. Use RabbitMQ when you need sophisticated routing logic, multi-protocol support, or traditional task queues. Use SQS when you want zero-ops simplicity in an AWS environment with reliable point-to-point queuing. Use SNS when you need to broadcast a single event to multiple subscribers or trigger serverless workflows.
Often the most powerful architectures combine these tools — for example, the classic SNS + SQS fan-out pattern, or using Kafka for high-throughput ingestion with RabbitMQ for fine-grained task routing downstream.
Ready to Build It Yourself?
Clone any of the three repositories and run them against a real broker to see Kafka streaming, RabbitMQ routing, and AWS SQS/SNS pub/sub in action.
About the Author
Wayne Cheng is the founder and AI app developer at Audoir, LLC. Prior to founding Audoir, he worked as a hardware design engineer for Silicon Valley startups and an audio engineer for creative organizations. He holds an MSEE from UC Davis and a Music Technology degree from Foothill College.
Further Exploration
Explore the complete tutorial repositories to experiment with advanced features:
- • Kafka Tutorial — Add stream processing with Kafka Streams or experiment with consumer group rebalancing
- • RabbitMQ Tutorial — Extend the exchange demos with message priorities or RabbitMQ Streams
- • SQS & SNS Tutorial — Implement dead letter queues, message filtering, and Lambda integration
For more AI-powered development tools and tutorials, visit Audoir .