# RabbitMQ and Managed Queues (SQS, Pub/Sub)

> Use a classic broker with routing, per-message acks and delays, or a managed cloud queue, when you need task distribution rather than a replayable log. Free...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/rabbitmq-and-managed-queues
Last updated: 2026-11-28

Use a classic broker with routing, per-message acks and delays, or a managed cloud queue, when you need task distribution rather than a replayable log.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Message Queues and Async Processing](https://www.internhack.in/roadmaps/tracks/system-design/message-queues)

If your main need is **distributing tasks to workers** rather than keeping a replayable event history, a classic message broker or a managed queue is simpler than Kafka.

### RabbitMQ

- Producers publish to **exchanges**; exchanges route to **queues** by rules:
- **Direct**: exact routing key match.
- **Topic**: wildcard patterns such as order.\*.created.
- **Fanout**: copy to every bound queue.
- Per-message **acks**, **prefetch** limits to stop one worker hogging messages, TTLs, dead-letter exchanges and priority queues.
- Messages are removed once acked, so there is no replay by default (RabbitMQ Streams add log-like behaviour).

### Managed cloud queues

- **Amazon SQS**: fully managed, scales without capacity planning. Standard queues give at-least-once delivery with best-effort order; FIFO queues give ordering per message group and deduplication with lower throughput.
- **Google Pub/Sub** and **Azure Service Bus**: similar managed options with pub/sub fan-out.
- Pair SQS with SNS for fan-out to multiple queues.

### Choosing between them and Kafka

- Task queue with retries, delays and priorities, modest volume: RabbitMQ or SQS.
- High-volume event stream, many consumers, replay needed: Kafka.
- Small team on AWS who wants zero ops: SQS plus SNS.

### Pitfalls

- Unbounded prefetch, so one slow consumer holds thousands of unacked messages.
- Assuming SQS standard queues deliver exactly once or in order.
- Running a self-managed broker cluster with no monitoring of queue depth and memory alarms.

You are ready to move on when you can set up a topic exchange that routes order events to three different worker queues and explain when you would pick SQS FIFO over a standard queue.

## Key concepts

- **Exchanges, queues and bindings**
- **Direct, topic and fanout exchanges**
- **Prefetch and acks**
- **Dead-letter exchanges**
- **SQS standard vs FIFO**
- **SNS + SQS fan-out**

## Other options for this step

- [Event Streaming with Kafka](https://www.internhack.in/roadmaps/tracks/system-design/kafka-event-streaming): Learn the log-based model behind Kafka: topics, partitions, offsets and consumer groups, and when a durable event stream beats a classic queue.

## Mini project

Build an order processing demo on RabbitMQ with a topic exchange routing to invoice, email and analytics queues, prefetch of 10, and a dead-letter exchange. Show what happens when the invoice worker throws for one specific order.

## Check yourself

Why does RabbitMQ not let a new consumer replay last week's messages, while Kafka does?

## Free resources

- [RabbitMQ tutorials](https://www.rabbitmq.com/tutorials) (RabbitMQ)
- [RabbitMQ documentation](https://www.rabbitmq.com/docs) (RabbitMQ)
- [Amazon SQS developer guide](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html) (AWS)

Previous: [Event Streaming with Kafka](https://www.internhack.in/roadmaps/tracks/system-design/kafka-event-streaming) · Next: [Delivery Guarantees and Event-Driven Design](https://www.internhack.in/roadmaps/tracks/system-design/delivery-semantics-event-driven)

## More in Queues, Streams and Asynchronous Processing

- [Message Queues and Async Processing](https://www.internhack.in/roadmaps/tracks/system-design/message-queues)
- [Event Streaming with Kafka](https://www.internhack.in/roadmaps/tracks/system-design/kafka-event-streaming)
- [RabbitMQ and Managed Queues (SQS, Pub/Sub)](https://www.internhack.in/roadmaps/tracks/system-design/rabbitmq-and-managed-queues)
- [Delivery Guarantees and Event-Driven Design](https://www.internhack.in/roadmaps/tracks/system-design/delivery-semantics-event-driven)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
