# FIFO queues

A FIFO queue delivers each message group in exactly the order it was sent, one consumer per group at a time, and drops a repeated send within five minutes.

Use a FIFO queue when order matters within something (one customer's orders, one document's
edits) and different groups may run in parallel. A queue is FIFO when it is created as one; its
name then ends in `.fifo`, and no other queue's name does. The type cannot be changed later. See
[Create a queue](create-a-queue.md).

## Message groups

Every send to a FIFO queue names a message group (`messageGroupId`, or `MessageGroupId` from an SQS
client): 1 to 128 letters, digits or punctuation characters. A send without one is refused.

- Messages of a group are delivered in the order they were sent.
- While any message of a group is in flight, no other message of that group is delivered, to
  anyone. Other groups are unaffected, so throughput grows with the number of groups being worked
  on.
- One receive can return several messages of a group, in order. Delete (or release) all of them
  before the group continues.
- If a message's visibility timeout ends, the group resumes from that message: the order holds,
  and the message is delivered again.

## Sequence numbers

Each message gets a sequence number, increasing within the queue and written as 20 digits. It is
in the send's answer (`sequenceNumber`, or `SequenceNumber` from an SQS client) and with the
message when you receive it.

## Deduplication

A send whose deduplication id belongs to a message stored on the queue less than five minutes ago
is accepted and not stored again. The five minutes count from that first send; a repeat does not
extend them. The answer carries the original message's id (and, from the API,
`duplicate: true`). The deduplication id is:

- the `messageDeduplicationId` (`MessageDeduplicationId`) of the send, or
- when the send has none and the queue has **content-based deduplication**, the SHA-256 of the
  body.

A send with neither is refused. Content-based deduplication can be turned on or off later with the
API, the CLI, Terraform or an SQS client; see [Change a queue's settings](change-queue-settings.md).

## Delays

A FIFO queue uses its own delivery delay for every message. A send that names a delay of its own is
refused.

## Dead-letter queues

The dead-letter queue of a FIFO queue must be a FIFO queue too. Messages moved to it, and messages
redriven out of it, keep their group and their order, and join the end of the queue they move to.
See [Dead-letter queues](dead-letter-queues.md).

## Related

- [Send messages](send-messages.md)
- [Message delivery](message-delivery.md)
