Stage 3 · Build
Caching, Queues & Background Jobs
Message Queues
Compare RabbitMQ, NATS, Kafka, and Redis Streams for durability, ordering, and delivery guarantees.
Why Message Queues
Message queues decouple producers from consumers. A service publishes a message and continues. Workers process messages asynchronously. This improves resilience, scalability, and response time.
RabbitMQ
RabbitMQ is a traditional message broker with exchanges, queues, and routing keys. It supports multiple protocols and provides strong delivery guarantees. Best for task queues and work distribution.
NATS
NATS is a lightweight, high-performance messaging system. It supports pub/sub, request-reply, and queue groups. NATS JetStream adds persistence, exactly-once delivery, and consumer groups.
Kafka
Kafka is a distributed event streaming platform. It stores messages in partitions on disk. Consumers track their position with offsets. Best for event sourcing, log aggregation, and high-throughput streaming.
Redis Streams
Choosing a Queue
| Queue | Best For | Delivery | Complexity |
|---|---|---|---|
| RabbitMQ | Task queues, routing | At-least-once | Medium |
| NATS | Lightweight pub/sub | At-most-once / JetStream | Low |
| Kafka | Event streaming, high throughput | At-least-once / exactly-once | High |
| Redis Streams | Simple streaming with existing Redis | At-least-once | Low |
If you already use Redis, Redis Streams are the simplest way to add async processing. For more advanced needs (partitioning, retention), graduate to Kafka or RabbitMQ.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.