Message Brokers: Kafka, RabbitMQ, NATS
How Kafka, RabbitMQ and NATS deliver messages, what each one guarantees, the patterns around them and how to choose — for backend interviews, with Go exercises.
Tests check every exercise: in your browser and in the cloud
To repeat the lessons' commands at home, run the three brokers in Docker. The exercises run in the browser and need none of this.
Docker Desktop
Download Docker Desktop for your system. On Linux, Docker Engine is enough.
Kafka
The official Kafka quickstart shows how to start a broker from the
apache/kafkaDocker image.RabbitMQ
The RabbitMQ download page describes how to start a broker with its management UI from the
rabbitmqDocker image.NATS
Run the NATS server from the
natsDocker image with JetStream switched on: the server needs its-jsflag, and thenatsimage page shows how to pass it. Then install thenatsCLI.
Syllabus
- Retries, backoff and dead lettersTheory
- Exercise: exponential backoff with jitterExercise
- Quiz — retriesQuiz
- The transactional outboxTheory
- Exercise: an outbox relayExercise
- Order per key and back-pressureTheory
- Exercise: a worker pool that keeps order per keyExercise
- Sagas in briefTheory
- Quiz — patternsQuiz