What is a message broker (e.g. Kafka or RabbitMQ) and how is it used in event-driven design?

Modern system architectures – and many system design interviews – frequently mention terms like message broker, Apache Kafka, or RabbitMQ. These technologies are at the heart of how distributed systems communicate. But what exactly is a message broker, and how does it fit into an event-driven design? In this article, we’ll demystify message brokers, explore how they are used in event-driven architectures, and explain why they’re a crucial concept in scalable system design. Along the way, we’ll share real-world examples, best practices, and tips to help you understand message brokers—knowledge that can give you an edge in your next technical interview.

Understanding Message Brokers

A message broker is essentially a software intermediary that helps different applications, services, or systems exchange information by sending each other messages. In simpler terms, it’s like a postal service for your software: one application “drops off” a message with the broker, and the broker makes sure it gets delivered to the right destination. The sender and receiver can be completely independent (even written in different programming languages or running on different platforms) because the broker handles the communication details.

Message brokers can hold onto messages and route them to the appropriate destinations when the time is right. The sending part of your system doesn’t need to know where the receiver is or even if it’s up – the broker queues the message and delivers it once the receiver is ready. In this way, no message is lost if a service is down, and no component waits around for another. This asynchronous style of communication makes the whole system more flexible, resilient, and efficient.

Two popular message brokers you’ll hear about are Apache Kafka and RabbitMQ. Both move data from producers (senders) to consumers (receivers), but they have different specialties. RabbitMQ is a general-purpose broker that pushes each message to a consumer and waits for an acknowledgement, ensuring reliable delivery. It’s great for use cases like background job processing or sending notifications – scenarios where every message matters and shouldn’t be lost.

Apache Kafka, by contrast, is a distributed event streaming platform. Kafka writes messages to a persistent log (organized into topics), and consumers pull from that log at their own pace. It’s built for high throughput and can broadcast streams of events to multiple consumers. This makes Kafka ideal for use cases like real-time analytics, log aggregation, and other situations where data streams need to be shared across many services.

Note: A quick terminology point – a message queue is where messages are stored temporarily, whereas a message broker is the system that manages and routes messages using such queues. They’re related but not identical. (See our guide on the differences between message brokers and message queues for more details.)

Message Brokers in Event-Driven Design

In an event-driven design (also called event-driven architecture), systems communicate by producing and reacting to events rather than calling each other directly. When something happens in one part of the system (say, a user signs up or makes a purchase), that component publishes an event message. Other components that care about that event can subscribe and respond to it. A message broker is often at the center of this design, making it all work.

Event-driven systems are typically broker-centric – the broker acts as the mediator for all events. It decouples event producers (services that publish events) from event consumers (services that handle events). The producers don’t need to know which service will pick up the event, or even if any service is listening. They just hand the event to the broker. The broker then delivers the event to all interested consumers, ensuring each gets the message without requiring a direct connection between producer and consumer.

Real-world example: Imagine an e-commerce system. When a customer places an order, the order service publishes an “Order Placed” event to the broker. Then multiple services can react: the payment service charges the customer’s card, the inventory service updates stock levels, and the notification service sends a confirmation email. All of them get the event from the broker and work in parallel, without the order service calling each one directly. This kind of loose coupling makes the system more scalable and maintainable. If you later add a new analytics service to track sales, you can simply have it subscribe to the same event — no changes needed to the order service.

Benefits of Using Message Brokers

Using a message broker in an event-driven (or any distributed) system provides many benefits:

  • Loose Coupling: Services don’t need direct knowledge of each other. A producer just sends messages, and one or many consumers can receive them. This makes it easier to add or change services without breaking the whole system.
  • Scalability: You can scale different parts of the system independently. If you have a spike in events, you can add more consumer instances to process messages in parallel from the broker’s queue or topic.
  • Reliability & Resilience: Because the broker can store messages until they’re delivered, temporary failures or slowdowns in one service won’t lose data. For example, if a consumer goes down, the broker will keep the messages and deliver them when it’s back up. This buffer capability adds fault tolerance.
  • Async Processing & Performance: Senders (producers) don’t have to wait for receivers to finish work. They can “fire and forget” an event to the broker and continue their own tasks. This non-blocking workflow means faster response times for user-facing actions. It’s like dropping a letter in the mail and moving on, instead of waiting on the phone for someone to pick up.
  • Flexibility: It’s easy to hook up new features. Want to add a new service that reacts whenever a user uploads a photo? Just subscribe that service to the relevant event on the broker. No need to modify the service that publishes the event. This makes adding features or tweaking the system architecture much simpler.

Brokers use two main messaging patterns: point-to-point queues (each message goes to one consumer) and publish-subscribe topics (each message can fan-out to multiple subscribers). Some systems focus on one model or the other, while many support both. There are also many types of message brokers – from lightweight in-memory brokers to distributed cloud services and enterprise service buses.

Best Practices for Using Message Brokers

Implementing a message broker effectively requires some careful consideration. Here are a few best practices from industry experience and technical interview tips:

  • Use Dead Letter Queues (DLQs): Plan for what happens if a message can’t be processed. Many brokers allow configuring a dead letter queue where messages go after certain failed attempts. This prevents one bad message from blocking the whole queue and allows later debugging.
  • Monitor and Scale: Keep an eye on your broker’s performance. Metrics like queue length, consumer lag, or throughput can tell you if the system is overwhelmed. If you see backlogs growing, you might need to add more consumers or scale up your broker cluster. System architecture is all about identifying bottlenecks and addressing them proactively.

By following these best practices, you’ll not only build more robust systems but also demonstrate experience and expertise in handling real-world messaging scenarios (a plus point for interviews!).

Message Brokers in System Design Interviews

Message brokers are a favorite topic in system design interviews because they illustrate how to build scalable and resilient systems. Interviewers might ask, for instance, “How would you design a ride-sharing system’s communication between services?” or “How can we decouple the components of an e-commerce platform?” Using a message broker is often a key part of good answers to questions like these, as it shows you understand asynchronous communication and loose coupling.

For example, if an interviewer asks how to handle spikes in traffic or tasks (say, a sudden surge of sign-up emails to send out), you can suggest putting the work into a message queue (managed by a broker) so that background workers can process them at their own pace. This demonstrates awareness of real-world solutions.

At DesignGurus.io, we’ve helped thousands of engineers prepare for these scenarios. Our Grokking the System Design Interview course covers real-world system design patterns like using message brokers, and provides plenty of practice problems. It’s full of technical interview tips and guidance on how to articulate your thought process. By practicing with these resources, you’ll get comfortable deciding when to use a message broker and explaining its benefits clearly – a skill that can really impress in an interview.

Frequently Asked Questions (FAQs)

Q1. What is a message broker used for?

A message broker is used to decouple and coordinate communication between different services or components. Instead of one service calling another directly (and waiting), the broker lets services exchange information via messages asynchronously. This is useful for distributed systems, microservices, and any scenario where you want reliable, flexible message passing without tight integration.

Q2. What is the difference between a message broker and a message queue?

A message queue is a place where messages are stored until a consumer retrieves them (usually first-in, first-out). A message broker is the service that manages these queues and routes messages between producers and consumers. In short, think of the queue as a mailbox and the broker as the postal service that makes sure messages get delivered.

Q3. Is Apache Kafka a message broker or a message queue?

Apache Kafka is essentially a distributed message broker (an event streaming platform). However, it doesn’t use a traditional queue system like RabbitMQ. Kafka stores messages in a persistent log (topics) and allows consumers to read from it at their own pace. In other words, Kafka does the job of a message broker but uses a log instead of a simple queue.

Conclusion

Message brokers like Kafka and RabbitMQ are fundamental building blocks in modern system architecture. They act like the postal service of your software, ensuring event messages get from senders to receivers efficiently, even in complex distributed environments. In an event-driven design, brokers enable loosely coupled, scalable, and resilient systems by letting services communicate asynchronously. In this article, we explored what message brokers are, how they support event-driven patterns, and why they matter – especially in system design interviews.

Ready to take your system design skills to the next level? Join our expert-led courses at DesignGurus.io to deepen your understanding and get hands-on practice. Our popular Grokking the System Design Interview course is a perfect next step – it will guide you through real scenarios and provide mock interview practice to solidify your knowledge. Sign up today and let us help you ace your next system design interview!

CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Image
One-Stop Portal For Tech Interviews.
Copyright © 2025 Design Gurus, LLC. All rights reserved.