The post office that stores, routes and delivers messages (Kafka, RabbitMQ, SQS).
A message broker is the software in the middle. It receives messages from producers, stores them safely, routes them and delivers them to consumers.
Without a broker, every service must call every other service and handle failures itself. With a broker, each service connects once, to the broker.
There are many products. They fall into two main styles. This is the general idea; each product has more features.
| Tool | Style | Good at |
|---|---|---|
| RabbitMQ | Routing broker with exchanges and queues | Task queues, flexible routing |
| Apache Kafka | Distributed log with partitions | Event streaming, replay, huge throughput |
| Amazon SQS | Managed queue | Simple background jobs with little to run |
| Amazon SNS / Google Pub/Sub | Managed topics for fan-out | Pub/Sub without running servers |
| Redis (lists, streams) | In-memory data store used as a light broker | Fast, simple jobs |
| Idea | Simple meaning |
|---|---|
| Exchange and binding | The router and its rules for sending messages to queues |
| Partition | One ordered log. More partitions means more parallel readers |
| Offset | The position of a consumer in a partition (โI have read up to 42โ) |
| Consumer group | A set of consumers that share a topic. Each partition goes to one member of the group |
| Retention | How long the broker keeps messages (time or size) |
| Replication | Copies of data on other brokers so one failure does not lose it |
| Lag | How far a consumer is behind the newest message |
| Term | Meaning in easy words |
|---|---|
| Broker | Software that stores, routes and delivers messages |
| Exchange | A router that sends a message to queues by rules |
| Binding | A rule that links an exchange to a queue |
| Topic | A named stream of messages |
| Partition | One ordered log inside a topic |
| Offset | A consumerโs position in a partition |
| Consumer group | Consumers that share the work of a topic |
| Retention | How long messages are kept |
| Replication | Keeping copies on several brokers |
| Lag | How far behind a consumer is |
| Ack | A signal that a message was handled |
| Throughput | Messages handled per second |
| Choice | We gain | We lose |
|---|---|---|
| Routing broker | Flexible routing, simple task queues | No built-in replay once acked |
| Log broker | Replay, many readers, huge volume | More to learn, order only per partition |
| Managed cloud broker | No servers to run | Less control, vendor lock-in, cost |
| Self-hosted broker | Full control | You run, patch and scale it |