Course contentsShow
← Software Engineering
Lesson 1365 of 1,93340. Event-Driven ArchitectureFree lesson

Choosing a Message Broker: RabbitMQ, Kafka, and Others

Compare popular brokers by throughput, latency, durability, and operational complexity to match architectural needs.

Choosing a Message Broker: RabbitMQ, Kafka, and Others

You'll learn: How to compare popular message brokers to select the right tool for your event-driven architecture needs.

The Selection Challenge

Not all message brokers are created equal. Think of choosing a broker like choosing a vehicle: a sports car, a cargo truck, and a bus all move people or goods, but they excel at different jobs. Similarly, RabbitMQ, Kafka, and other brokers each shine in different scenarios based on throughput, latency, durability, and operational demands.

RabbitMQ: The Flexible Messenger

Strengths: Low latency (milliseconds), sophisticated routing (exchanges, bindings), easy to set up, strong support for at-most/at-least-once delivery.

Trade-offs: Lower throughput than Kafka (~10k-100k messages/sec per broker), message deletion after consumption, more complex clustering.

Best for: Traditional request-reply patterns, complex routing needs, task queues, when you need message acknowledgment and don't require retention.

Apache Kafka: The Event Log

Strengths: Exceptional throughput (millions of messages/sec), message retention (events aren't deleted), horizontal scalability, strong partitioning for ordering, natural fit for event sourcing.

Trade-offs: Higher latency (tens of milliseconds), more operational complexity (ZooKeeper/KRaft), steeper learning curve, messages stored even after consumption.

Best for: High-volume streaming, event sourcing, building projections, when you need message replay, analytics pipelines.

Other Options

Redis Streams: Ultra-low latency, simpler than both, limited durability guarantees.

AWS SQS/SNS: Managed simplicity, cloud-native, but vendor lock-in.

Decision Framework

Match your architecture's priorities: Need complex routing? RabbitMQ. Need high throughput and event replay? Kafka. Need simplicity and can tolerate message loss? Redis. Operating in the cloud? Consider managed services.

Key Takeaway: Choose RabbitMQ for traditional messaging with flexible routing, Kafka for high-throughput event streaming and retention, and evaluate operational complexity against your team's expertise and architectural requirements.