14 - Decoupling Applications SQS SNS Kinesis MQ

SQS - FIFO Queues

awssqsfifoorderingsaa-c03

Overview

FIFO means first in, first out, the ordering of messages in the queue. If a producer sends messages 1, 2, 3, 4 in order, the consumer polling a FIFO queue reads them in the same order. This guarantee does not hold for a regular SQS queue, where messages can be received out of order.

FIFO Attributes

Attribute Value
Ordering Guaranteed, per message group ID
Throughput 300 messages per second without batching, 3,000 messages per second with batching (defaults without high-throughput mode) (limited because of the ordering guarantee)
Exactly-once send Duplicates removed at the queue level using a deduplication ID
Deduplication window If the same ID is seen twice within 5 minutes, the duplicate is removed
Queue name Must end with .fifo
AWS update (2021-05)

300/s and 3,000/s batched are the defaults without high-throughput mode. FIFO high-throughput mode reaches up to 70,000 TPS non-batched in us-east-1, us-west-2 and eu-west-1, and less in other Regions. The exam may still use the course figures. AWS source

  • You must send a message group ID with every message. All messages for that group ID are processed in order.
  • Content-based deduplication is a queue setting that deduplicates the same message sent twice in the five-minute window.
Exam Pattern

Need ordering and no duplicates -> SQS FIFO. Ordering is at the message group ID level. Dedup window is 5 minutes.


Hands-On Walkthrough

  1. Create queue, choose FIFO (first-in-first-out delivery, message ordering preserved).
  2. Name it DemoQueue.fifo. The name must end with .fifo, otherwise you cannot create it.
  3. Configuration is similar to a standard queue, with one extra setting: content-based deduplication. Access policy and encryption stay the same. Click Create queue.
  4. Send and receive messages. Body Hello World 1, message group ID demo (the same for all messages in the demo), deduplication ID 1. Send.
  5. Repeat for Hello World 2 (dedup ID 2), Hello World 3 (3), Hello World 4 (4), all with group ID demo.
  6. 4 messages are available. Poll for 4 messages. The list is displayed in reverse, so read it from the bottom: Hello World 1, 2, 3, 4 in order. This is the FIFO guarantee.
  7. Delete the messages.

Questions & Answers

Q1: What does a FIFO queue guarantee?

Answer:

Messages are received in the order they were sent, per message group ID, with exactly-once send via deduplication.

Q2: What is FIFO throughput?

Answer:

300 msg/s without batching, 3,000 msg/s with batching (defaults; high-throughput mode is higher).

Q3: How are duplicates removed?

Answer:

With a deduplication ID on each message (or content-based deduplication). A repeat within 5 minutes is dropped.

Q4: What naming rule applies to FIFO queues?

Answer:

The name must end with .fifo.

Check yourself

Quiz

Flashcards

Click the card (or focus it), then use ← → to move and Space to flip.