AWS SQS FIFO Queue vs Standard Queue

Aparna VikramanAparna Vikraman
3 min read

Amazon SQS offers two types of queues: FIFO (First-In-First-Out) and Standard. Let's explore their pros and cons to help choose the right queue for your application.

FIFO Queues

FIFO queues guarantee that messages are processed in the exact order they are sent, with no duplicates.

When to choose

  • The order of operations and events is critical (e.g., financial transactions, order processing).

  • The system needs the message processed exactly once and can't tolerate duplicates.

  • The system can work within the throughput limits of FIFO queues.

Pros of FIFO Queues

  1. Strict Ordering: Messages are processed in the exact sequence in which they have entered the queue.

  2. Exactly-Once Processing: FIFO queues prevent message duplication, ensuring each message is processed only once.

  3. Message Group Support: Allows for ordered processing of related messages within defined groups.

  4. Deduplication: Offers built-in deduplication for a 5-minute interval, based on a unique ID or message content.

Cons of FIFO Queues

  1. Limited Throughput: FIFO queues are limited to 300 transactions per second (3,000 with batching).

  2. Higher Cost: FIFO queues are generally more expensive than standard queues.

  3. Limited AWS Service Integration: Not all AWS services support FIFO queues (e.g., CloudWatch Events, S3 Event Notifications).

  4. Naming Restriction: FIFO queue names must end with the .fifo suffix.

Standard Queues

Standard queues offer high throughput with best-effort ordering and at least once delivery.

When to choose

  • The system needs maximum throughput and can handle occasional out-of-order messages.

  • The system can process potential duplicate messages.

  • The system needs integration with AWS services that don't support FIFO queues.

  • Cost is a primary concern, and the system doesn't require strict ordering or deduplication.

Pros of Standard Queues

  1. High Throughput: Support nearly unlimited transactions per second.

  2. Lower Cost: Generally less expensive than FIFO queues.

  3. Wide AWS Service Support: Compatible with most AWS services.

  4. Scalability: Easily scale to handle increased load without additional configuration.

Cons of Standard Queues

  1. No Guaranteed Ordering: Messages may occasionally be delivered out of order.

  2. Potential Duplicates: Messages might be delivered more than once, requiring application-level deduplication.

  3. No Message Group Support: Cannot group related messages for ordered processing.

Performance Considerations

When using FIFO queues, you can optimize performance by:

  1. Utilizing message batching to increase throughput by up to 3,000 messages per second.

  2. Designing message group IDs to allow parallel processing where possible.

For standard queues, focus on:

  1. Implementing application-level deduplication if needed.

  2. Use long polling to reduce the number of empty receives and minimize cost.

Cost Implications

While FIFO queues offer stronger guarantees, they come at a premium:

  • FIFO queues cost $0.50 per million API requests

  • Standard queues cost $0.40 per million API requests

This represents about a 25% higher cost for FIFO queues. Consider this difference when designing high-volume systems.

In conclusion, the choice between FIFO and Standard queues depends on the specific application requirements. If strict ordering and exact-once processing are crucial, FIFO queues are the way to go. For high-throughput scenarios where occasional duplicates or out-of-order messages are acceptable, standard queues offer a more cost-effective and scalable solution.

0
Subscribe to my newsletter

Read articles from Aparna Vikraman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aparna Vikraman
Aparna Vikraman