> For the complete documentation index, see [llms.txt](https://dianadarie.gitbook.io/system-design-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dianadarie.gitbook.io/system-design-notes/basics/message-queues.md).

# Message Queues

*= durable component, stored in memory, that supports asynchronous communication. Helps reduce request times for expensive operations that would otherwise be performed in-line. Receives, holds, and delivers messages.*

<figure><img src="/files/iY9qYIAtVwuoTwUpNHwX" alt=""><figcaption></figcaption></figure>

If an operation is too slow to perform inline, you can use a message queue with the following workflow:

* An application publishes a job to the queue, then notifies the user of job status.
* A worker picks up the job from the queue, processes it, then signals the job is complete.

e.g. RabbitMQ, Amazon SQS

## SQS

* supports <mark style="color:yellow;">**dead-letter queues (DLQ)**</mark> - useful for debugging your application or messaging system because they let you isolate unconsumed messages to determine why their processing doesn't succeed.
* supports <mark style="color:yellow;">**visibility timeout**</mark> - When a consumer receives and processes a message from a queue, the message remains in the queue. SQS doesn't automatically delete the message, the consumer needs to. To prevent other consumers from processing the message again, SQS sets a *visibility timeout*, a period of time during which Amazon SQS prevents all consumers from receiving and processing the message. - a message is hidden *only after it is consumed from the queue*.
* supports <mark style="color:yellow;">**delay queues**</mark> - let you postpone the delivery of new messages to consumers for a number of seconds -  a message is hidden *when it is first added to queue*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dianadarie.gitbook.io/system-design-notes/basics/message-queues.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
