SQS FIFO [Everything that you should know]

Bits Lovers
Written by Bits Lovers on
SQS FIFO [Everything that you should know]

SQS FIFO vs Standard Queue: What You Need to Know

This is a follow-up to our standard SQS queues post. If you haven’t read that one first, do that before continuing here.

The Core Differences

Standard queues don’t promise anything about message order. Send five messages (1, 2, 3, 4, 5) and you might get them back as 3, 5, 1, 2, 4. Duplicates can show up too.

FIFO queues work differently. Messages come out in the exact order you sent them, and you won’t see the same message twice.

How SQS FIFO compares to Standard Queue

Feature Standard Queue FIFO Queue
Message Ordering Best-effort only Guaranteed
Message Duplication Possible Not possible
Throughput Unlimited 300 messages/sec (up to 3,000 with batching)

When Should You Use Each?

Pick a standard queue when:

  • Message order doesn’t matter (processing hashtags, for example)
  • You need high throughput
  • Cost is a primary concern

Pick a FIFO queue when:

  • Order is critical (financial transactions, inventory updates)
  • You need exactly-once processing
  • Your throughput stays under 3,000 messages/sec with batching

How FIFO Works

Send five messages (1, 2, 3, 4, 5) and they arrive in that exact order. No duplicates. AWS holds messages in the sequence they arrived.

So why would anyone use a standard queue? Standard queues handle practically unlimited transactions per second. You can have dozens of readers and writers hitting the queue without hitting a wall.

FIFO caps you at about 300 messages per second per queue, or up to 3,000 if you batch using SendMessageBatch (which lets you send up to 10 messages per call). It’s also more expensive because AWS does extra work to maintain ordering and deduplication.

There’s a trade-off here. Sometimes the simpler queue is the right answer.

FIFO Queue Features

Message Group ID

This field groups messages together. All messages with the same group ID stay in their original sequence, and none get duplicated within that group. You’ll need this when you configure a FIFO queue.

Note: You can’t ask SQS to deliver messages from a specific group ID only. SQS controls the ordering across groups.

Message Deduplication ID

This prevents duplicate messages. SQS uses a deduplication interval of five minutes. If you send the same message with the same deduplication ID within that window, SQS accepts it but doesn’t deliver it to consumers. You only see it once.

Here’s how it works. You send a message with group ID “orders” and deduplication ID “order-12345”. Send it five times. The consumer receives it once.

Content-based deduplication is an alternative. Enable it on the queue and SQS generates a SHA-256 hash of the message body to determine deduplication. You don’t need to set a deduplication ID yourself.

Exam Tips

If you’re studying for an AWS exam, keep these points in mind:

  • FIFO is your answer when message ordering or message deduplication shows up as a requirement. Standard queues can’t guarantee either.
  • FIFO caps at roughly 300 messages per second without batching, or 3,000 with batching. If a question mentions thousands of transactions per second, FIFO isn’t the right choice.
  • FIFO queue names must end with .fifo. That suffix counts against the 80-character queue name limit.
  • Message group ID keeps messages within a group in sequence. But batches from different groups can arrive in any order. The guarantee is only within a single group.
  • FIFO costs more than standard. AWS spends compute cycles on ordering and deduplication.

Check out what standard SQS queues are and when to use Dead-Letter Queues to round out your SQS knowledge.

Become AWS Expert

What is High Availability on AWS?

Bits Lovers

Bits Lovers

Professional writer and blogger. Focus on Cloud Computing.

Comments

comments powered by Disqus