Skip to content

AWS Technologies Blog

Menu
  • Home
  • KB
  • Services
  • Resources
  • Posts
  • Find
    • Categories
    • Tags
  • About
Menu

SQS

Posted on February 25, 2025March 21, 2025 by wpadmin
FeatureStandard QueueFIFO Queue
ThroughputUnlimited300 TPS (default) 3,000 TPS (with high-throughput mode)
Message per secondVirtually unlimitedLimited to configured TPS
OrderingBest-effort (out of order possible)Strictly ordered
DuplicatesPossible (at-least-once delivery)No duplicates (exactly-once processing)
LatencyTens of millisecondsSlightly higher due to ordering enforcement
Message SizeUp to 256 KB per messageUp to 256 KB per message
Message Retention1 minute to 14 days (default 4 days)1 minute to 14 days (default 4 days)
Visibility Timeout0 seconds to 12 hours0 seconds to 12 hours
BatchingSupports up to 10 messages per batchSupports up to 10 messages per batch
DeduplicationNot availableRequires a deduplication ID
CostLower cost per requestSlightly higher cost due to ordering and deduplication overhead

Key Limitations

  • FIFO queues have a lower throughput cap compared to standard queues.
  • FIFO queues require a deduplication ID or content-based deduplication.
  • Standard queues do not guarantee exactly-once processing, so duplicates should be handled at the application level.
  • Both queues have a maximum message size of 256 KB.
  • Visibility timeout must be set appropriately to prevent multiple consumers from processing the same message.

Comparison Table: Short Polling vs. Long Polling

FeatureShort PollingLong Polling
Polling MethodPolls immediately, returns quickly even with no messages.Waits up to 20 seconds for messages, reduces empty responses.
CostCan result in unnecessary costs due to frequent empty responses.More cost-effective because it reduces empty requests.
LatencyPotentially higher latency due to multiple empty requests.Lower latency for message retrieval, reduces waiting time.
EfficiencyLess efficient because of repeated empty responses.More efficient by reducing the number of empty requests.
TimeoutNo wait time; responds immediately.Waits up to 20 seconds (configurable).
Use CaseGood for quick, frequent checks, but can result in unnecessary polling.Ideal for low-latency applications, reduces unnecessary costs.
Default SettingDefault polling method for SQS.Can be enabled by setting WaitTimeSeconds in the SQS receive request.

Visibility Timeout

The Visibility Timeout is a key setting in Amazon Simple Queue Service (SQS) that defines the amount of time a message remains hidden from other consumers after it has been received by a consumer. This prevents multiple consumers from processing the same message simultaneously.


1. How Visibility Timeout Works

  1. Message Received: When a consumer (e.g., EC2 instance, Lambda function) receives a message from the SQS queue, the message becomes invisible to other consumers for the duration of the Visibility Timeout period.
  2. Processing Time: During this timeout, the message is being processed, and no other consumer can pick it up until the timeout expires.
  3. Message Deletion or Visibility Reset:
    • If processed successfully, the consumer deletes the message from the queue.
    • If processing fails or times out, the message becomes visible again after the timeout period ends, allowing another consumer to attempt processing.

2. Visibility Timeout Settings

  • Default Timeout: The default visibility timeout for a new SQS queue is 30 seconds.
  • Maximum Timeout: The maximum allowed visibility timeout is 12 hours.
  • Adjustable Timeout: You can configure the visibility timeout for each queue, and you can also override the default for individual message retrieval operations.

How Batching Works in Amazon SQS

Batching in Amazon SQS allows you to send, receive, and delete multiple messages in a single API request. This helps reduce costs and improves efficiency.


1. SendMessageBatch (Sending Messages in Bulk)

  • Allows sending up to 10 messages in a single API call.
  • Each message in the batch must be ≀ 256 KB.
  • If any message in the batch fails, only that message failsβ€”the rest are processed.
  • Cost-saving: Batching reduces API costs by decreasing the number of requests.

2. ReceiveMessage (Receiving Messages in Bulk)

  • Can retrieve up to 10 messages in a single API call.
  • Messages are returned only if they are available.
  • The batch size can be adjusted using the MaxNumberOfMessages parameter (1-10).

3. DeleteMessageBatch (Deleting Messages in Bulk)

  • Allows deleting up to 10 messages in a single request.
  • Each message is identified by its receipt handle.
  • If deletion of a message fails, only that message needs retrying, not the whole batch.

Batching Limitations

LimitationDescription
Max Batch Size10 messages per batch
Max Message Size256 KB per message
Partial FailuresSome messages in a batch may fail while others succeed
FIFO Queue ConsiderationMaintains order within a batch but order across batches is not guaranteed

Amazon SQS Throttling Limits

Throttling in Amazon SQS occurs when API requests exceed the allowed rate limits. These limits vary based on the queue type (Standard vs. FIFO) and whether high-throughput mode is enabled.


1. Throttling Limits for SQS Queues

Queue TypeMax Requests per Second (TPS)High-Throughput ModeNotes
Standard QueueVirtually unlimitedN/ANo hard limit, scales automatically
FIFO Queue (default)300 TPS per API action (send, receive, delete)NoLimited to 300 TPS
FIFO Queue (high-throughput)3,000 TPS per API actionYesRequires enabling high-throughput mode

2. What Happens When Throttling Occurs?

If you exceed the allowed API request rate:
πŸ”΄ AWS returns a ThrottlingException (HTTP 429).
πŸ”΄ Requests may be delayed or dropped.
πŸ”΄ Message processing may slow down due to retries.

AWS SQS FIFO Deduplication ID

In AWS SQS FIFO (First-In-First-Out) queues, the Deduplication ID is used to prevent duplicate messages from being processed within a 5-minute deduplication window.


How the Deduplication ID Works

  • When you send a message to an SQS FIFO queue, AWS checks its Deduplication ID.
  • If another message with the same Deduplication ID was sent within the last 5 minutes, SQS ignores the new message to prevent duplication.
  • After 5 minutes, the same Deduplication ID can be used again.

Ways to Set the Deduplication ID

  1. Manually Specify the Deduplication ID
    • You can provide a custom Deduplication ID when sending a message.
    • Example: jsonCopyEdit{ "MessageBody": "Hello, FIFO Queue!", "MessageGroupId": "group-123", "MessageDeduplicationId": "unique-id-456" }
    • The MessageDeduplicationId must be unique within the 5-minute window.
  2. Content-Based Deduplication (AWS-Generated ID)
    • If you do not specify a Deduplication ID, AWS generates one automatically using an SHA-256 hash of the message body.
    • Two messages with the same body will be considered duplicates within the 5-minute window.

AWS SQS FIFO – Message Group ID

In AWS SQS FIFO (First-In-First-Out) queues, the Message Group ID is used to ensure that messages in the same group are processed in order by a single consumer.


How the Message Group ID Works

  1. Every message in an SQS FIFO queue must have a Message Group ID.
  2. Messages with the same Message Group ID are processed sequentially by a single consumer.
  3. Different Message Group IDs can be processed in parallel by multiple consumers.
  4. A consumer must delete a message before SQS delivers the next message in the same group.

  • Product List
  • Documentation

billing ciem containers cost cspm ebs ec2 ecs edge eks elb event Firewall fsx hybrid iam lambda NACL outpostd policies pop princing rds route53 s3 security serverless services SG siem storage vpc

  • Amazon FSx
  • aws
  • aws notes
  • billing
  • cloud
  • compute
  • containers
  • core
  • databases
  • development
  • ebs
  • ec2
  • ecs
  • edge
  • efs
  • eks
  • hybrid
  • iam
  • lambda
  • network
  • outposts
  • pricing
  • rds
  • route53
  • s3
  • security
  • serverless
  • services
  • storage
  • support
  • vpc
©2025 AWS Technologies Blog | Built using WordPress and Responsive Blogily theme by Superb