Amazon Simple Queue Service (Amazon SQS)
Cloud service · AWS · Updated

Amazon Simple Queue Service (Amazon SQS)

In short

Amazon Simple Queue Service (Amazon SQS) is a scalable, fully managed message queuing service that enables the decoupling and scaling of microservices, distributed systems, and serverless applications.

Cloud Services Hub →

10 key features of Amazon Simple Queue Service (Amazon SQS)

Amazon Simple Queue Service (Amazon SQS) is a fully managed message queuing service that enables the decoupling and scaling of microservices, distributed systems, and serverless applications through secure, durable, and highly available message queues.

01
Scalability

Amazon SQS automatically scales according to the demand of message throughput without needing to provision resources in advance, ensuring that your application can handle high volumes of messages without any manual intervention.

02
Durability

SQS provides high message durability, storing messages across multiple Availability Zones to prevent loss and ensuring that messages are available whenever you need them.

03
Security

SQS includes features like server-side encryption (SSE) to protect messages at rest, AWS Identity and Access Management (IAM) for controlling access, and VPC Endpoints to keep traffic within the AWS network, enhancing the security of your message queues.

04
Ease of Use

SQS allows for easy queue setup and operation with a simple web services interface to delete, send, and receive messages. The AWS Management Console provides a quick and intuitive interface for managing your queues.

05
Delay Queues

SQS supports delay queues, enabling you to postpone the delivery of new messages to a queue for a number of seconds, making it easier to design and manage time-dependent operations within your applications.

06
Dead Letter Queues

SQS supports dead letter queues, which can help in troubleshooting and resolving issues related to the processing of messages by automatically redirecting undeliverable messages to a separate queue.

07
Cost-effectiveness

With SQS, there is no upfront cost, and you pay as you go based on the number of requests made, as well as applicable data transfer, making it a cost-effective solution for message queuing.

08
Large Payload Offloading

Payloads larger than 1 MiB can be stored in Amazon S3, with Amazon SQS holding a pointer to the S3 object; alternatively, a large message can be split into smaller messages.

09
Message Attributes

Each message can contain up to 10 metadata attributes.

10
Message Batching

A single message batch request can include up to 10 messages.

Where Amazon Simple Queue Service (Amazon SQS) is used

Amazon Simple Queue Service (Amazon SQS) is primarily used for decoupling distributed system components, ensuring message durability and delivery, and scaling applications by managing communication between components and microservices efficiently.

  1. 01
    Decoupling Microservices

    Amazon SQS enables independently designed microservices to communicate with each other over the cloud. This decoupling reduces system complexity by allowing services to interact asynchronously, thereby increasing flexibility and scalability. It facilitates the transmission of messages or notifications between services, ensuring that each component functions efficiently without being directly dependent on others.

  2. 02
    Load Balancing

    In applications that experience variable loads, Amazon SQS can be used to balance loads between different components of the system. By queuing incoming tasks and processing them at a manageable rate, it ensures that no single component is overwhelmed. This improves the overall responsiveness and reliability of the application, as tasks are methodically distributed and processed.

  3. 03
    Delayed Processing

    Amazon SQS allows developers to delay the delivery of messages up to 15 minutes. This feature is useful in scenarios where processing of tasks needs to be postponed, such as rate-limited API calls where a cooldown period is necessary. By leveraging delayed messages, applications can efficiently manage task execution timing, optimizing resource use and adhering to operational constraints.

  4. 04
    Scalable Communication in IoT Applications

    For Internet of Things (IoT) applications that require scalable and reliable messaging between devices and services, Amazon SQS offers a robust solution. It can handle huge volumes of messages generated by IoT devices, enabling secure and scalable communication channels. This ensures that data collected from devices can be processed and analyzed in real-time or batch mode, facilitating timely decision-making and actions based on IoT data insights.

  5. 05
    Order Processing Pipeline

    Amazon SQS is ideal for managing orders in e-commerce applications, where it serves as a queue for incoming orders. It acts as a buffer between the order submission interface and the order processing service, ensuring that each order is processed systematically. By decoupling the order submission from the processing, it enhances the system's ability to scale and manage peak loads, such as during sales or promotional events, while maintaining order integrity and processing efficiency.

How Amazon Simple Queue Service (Amazon SQS) is priced

Amazon SQS pricing models typically include a pay-as-you-go approach based on the number of requests made, with additional costs for features like data transfer and optional services such as Amazon SQS FIFO (First-In-First-Out) queues.

Standard Queues

For Standard Queues, Amazon SQS charges based on the number of requests made. This includes actions such as SendMessage, ReceiveMessage, and DeleteMessage. Pricing is calculated per million requests after the free tier is exceeded.

FIFO Queues

FIFO (First-In-First-Out) queues have a different pricing model, focusing on the higher reliability and message ordering guarantees. API actions for sending, receiving, deleting, and changing message visibility are charged at FIFO rates, calculated per million requests after the free tier limit. All other API requests are charged at standard rates.

Data Transfer

AWS does not charge for data transfer when sending messages to or receiving messages from Amazon SQS if all resources are in the same AWS region. For cross-region data transfer and data transfer to or from the internet, standard AWS Data Transfer Charges apply.

Free Tier

Amazon SQS offers a free tier, available to both new and existing customers. The free tier includes 1 million requests per month for both Standard and FIFO queues. This does not include data transfer costs, which are billed separately.

Fair Queues

Sending, receiving, deleting, and changing message visibility in standard queues incur both fair queue rates and standard queue rates when at least one message with a message group ID is involved. All other API requests are charged only standard rates.

AWS KMS Requests

When AWS KMS manages keys for SQS server-side encryption, calls from Amazon SQS to AWS KMS incur AWS KMS charges.

Amazon S3 Payload Storage

Using the Amazon SQS Extended Client Library to send payloads through Amazon S3 incurs charges for the Amazon S3 storage used for those payloads.

Services Amazon Simple Queue Service (Amazon SQS) works with

Amazon API GatewayAmazon API Gateway

Amazon SQS can receive messages directly from API Gateway through an AWS service integration, without an intermediary Lambda function. An API endpoint can enqueue incoming requests for asynchronous processing.

Amazon CloudWatchAmazon CloudWatch

Amazon SQS publishes queue metrics to CloudWatch, including visible message counts, in-flight messages, and the approximate age of the oldest message. CloudWatch alarms can notify operators when a backlog grows or messages remain unprocessed.

Amazon DevOps GuruAmazon DevOps Guru

Amazon SQS queues are supported resources for DevOps Guru operational analysis. DevOps Guru analyzes queue metrics to identify anomalous behavior and surface related operational insights.

Amazon EC2 Auto ScalingAmazon EC2 Auto Scaling

Amazon SQS queues can receive EC2 Auto Scaling lifecycle notifications for instance launches and terminations. A lifecycle-hook consumer can perform initialization or cleanup before allowing the instance transition to continue.

Amazon EventBridgeAmazon EventBridge

Amazon SQS queues can receive events from EventBridge rules and serve as dead-letter queues for failed event deliveries. EventBridge Pipes can also poll an SQS queue, filter and enrich its messages, and deliver them to a configured target.

Amazon Managed Service for Apache FlinkAmazon Managed Service for Apache Flink

Amazon SQS can receive streaming output from Managed Service for Apache Flink applications through the Amazon SQS sink connector. The connector supports asynchronous, batched message delivery to a queue.

Amazon OpenSearch ServiceAmazon OpenSearch Service

Amazon SQS queues can supply S3 object notifications to OpenSearch Ingestion pipelines. A pipeline consumes the notifications, retrieves the referenced objects, and ingests their contents into an OpenSearch destination.

Amazon S3Amazon S3

Amazon SQS queues can receive S3 event notifications when objects are created, removed, or undergo other supported changes. The SQS Extended Client Library also stores large message payloads in S3 and places references to those objects in queue messages.

Amazon Security Lake

Amazon SQS queues deliver notifications about new Security Lake data to subscribers with data access. Subscribers consume these notifications to locate and retrieve security log objects from S3.

What is Amazon Simple Queue Service (Amazon SQS)

3 min read

Amazon Simple Queue Service (Amazon SQS) is a fully managed message queuing service designed to decouple and scale microservices, distributed systems, and serverless applications. Amazon SQS simplifies the complexity and overhead involved in managing and operating message-oriented middleware systems. 

It delivers a robust, secure, and highly scalable solution that allows developers to focus on building functionality rather than worrying about the underlying infrastructure required to pass messages between different components of an application. 

The core premise of Amazon SQS is to send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available. This makes it an incredibly valuable tool for building applications that require communication and coordination between separate services, such as order processing workflows, distributed systems where different components perform different tasks, and applications that must process actions initiated by users or services. 

Receiving a message does not delete it: it remains in the queue and is hidden from subsequent receive requests for the visibility timeout. The consumer must delete the message after processing to prevent it from being received and processed again when that timeout expires.

Messages expire automatically after the queue's retention period. The default is 4 days, configurable from 60 seconds to 14 days.

One of the key features of Amazon SQS is its support for two types of queues: Standard Queues and FIFO (First-In-First-Out) Queues. Standard Queues offer maximum throughput, best-effort ordering, and at-least-once delivery, which means messages are delivered at least once, but not necessarily in the exact order they were sent. On the other hand, FIFO Queues are designed to guarantee that messages are processed exactly once, in the order that they are sent, which is critical for certain business operations that cannot tolerate duplicate processing or out-of-order messages. 

Fair queues extend standard queues to mitigate noisy-neighbor impact in multi-tenant systems, helping maintain consistent message dwell times across tenants while retaining standard queue scalability and throughput.

Security in Amazon SQS is robust, offering encryption in transit and at rest, ensuring that messages are protected against unauthorized access. Additionally, Amazon SQS is integrated with AWS Identity and Access Management (IAM), allowing fine-grained control over who can send and receive messages on each queue. Amazon SQS is designed for high availability and durability. Messages stored in SQS are automatically replicated across multiple servers and data centers to prevent loss, ensuring that the system is resilient to failures and that messages are available when needed. 

Server-side encryption uses Amazon SQS managed encryption by default; custom encryption keys managed in AWS KMS are another option.

The service is also highly scalable, allowing applications to send and receive thousands of messages per second. This scalability is mostly transparent to the user, as Amazon SQS can automatically adjust to changes in the volume of message traffic without any manual intervention, making it a perfect match for applications that experience variable workloads. 

Stored-message counts are unlimited, but in-flight messages—received by a consumer and not yet deleted—are limited. Most standard queues have a limit of approximately 120,000 in-flight messages and return an OverLimit error when it is reached; FIFO queues have a limit of 120,000 and return no error when it is reached.

FIFO queues also offer a high throughput mode that you can enable in the Amazon SQS console. This mode supports up to 70,000 messages per second without batching and higher throughput with batching, with quotas varying by region.

Pricing for Amazon SQS is based on usage without any upfront costs, making it an economical choice for businesses of all sizes. Request fees are based on billable API requests rather than individual messages: every Amazon SQS action counts as a request, and each 64 KB chunk of a payload is billed as one request. This pay-as-you-go model allows businesses to start small and scale as their needs grow, without incurring significant initial costs. 

Overall, Amazon Simple Queue Service is a highly reliable, secure, and scalable service that simplifies the task of message queuing for developers. Its wide range of features, combined with its integration into the AWS ecosystem, makes it an essential tool for modern application development, particularly in environments where services need to communicate asynchronously.

Amazon Simple Queue Service (Amazon SQS) exam questions

Real practice exam questions on Amazon Simple Queue Service (Amazon SQS), with the correct answer and its explanation. Answer them with every option in the exam simulator.

CLF-C02

A warehouse application sends inventory updates to a separate processing application. Updates for the same product must be retrieved in the order they were sent because processing a stock reduction before an earlier stock increase could produce an incorrect result. The company wants a fully managed messaging solution without building custom message-reordering logic. Which solution best meets these requirements?

Show answerCORRECT ANSWER

Send updates to an Amazon SQS FIFO queue, using the product identifier as the message group ID.

An SQS FIFO queue preserves message order within each message group. Grouping updates by product ensures that updates for the same product are retrieved in the order they were sent.

SOA-C03

A company routes operational incident events through an Amazon EventBridge rule to an Amazon SQS FIFO queue. Each source event contains a unique incidentId. An input transformer produces a message body containing only the service name and severity. The target uses a fixed MessageGroupId. The queue has content-based deduplication enabled, with deduplication scoped to the entire queue.

During testing, several distinct incidents for the same service and severity occur within five minutes. EventBridge reports successful target invocations, but the queue receives only one message. Consumers are paused, and no delivery errors occur.

A CloudOps engineer must ensure that every distinct incident reaches the queue while duplicate deliveries of the same incident within five minutes remain suppressed. Which change meets these requirements?

Show answerCORRECT ANSWER

Update the input transformer to include incidentId in the message body while keeping the existing fields and content-based deduplication enabled.

SQS content-based deduplication hashes the message body. The current transformer makes distinct incidents with the same service and severity produce identical bodies, so SQS suppresses them within the five-minute deduplication interval. Including the stable incidentId gives distinct incidents different bodies while repeated deliveries of the same incident retain identical bodies.

SAP-C03

A logistics company processes shipment updates for 20 external partners. Updates enter one Amazon SQS Standard queue. An Amazon EC2 Auto Scaling group spans three Availability Zones, and every worker can process updates for any partner. Processing an update requires a synchronous call to that partner's API.

During an incident, one partner's API began responding very slowly. Updates for that partner occupied nearly all worker execution slots, and its growing backlog delayed updates for healthy partners. The workers remained healthy. Adding instances helped temporarily, but the affected partner eventually consumed the additional capacity.

The company requires healthy partners to continue meeting their processing latency targets throughout another partner's prolonged API degradation. Updates must remain queued for eventual processing during outages of up to 24 hours. Each partner's normal peak workload is known, and sufficient capacity can be provisioned in advance. The ingestion tier and other dependencies have sufficient capacity and are not bottlenecks.

Which architecture change meets these requirements?

Show answerCORRECT ANSWER

Create one SQS queue and one dedicated Auto Scaling group for each partner. Route updates to the appropriate queue, and restrict each group to consuming only its partner's queue. Preprovision each group for that partner's normal peak and configure queue retention to exceed the outage and recovery period.

Separating both queues and worker fleets contains the degraded partner's backlog and occupied execution slots. Healthy partners retain their own preprovisioned processing capacity. Sufficient queue retention preserves affected updates until the partner recovers and the backlog can be processed.

Practice Amazon Simple Queue Service (Amazon SQS) in a full exam

Questions on Amazon Simple Queue Service (Amazon SQS) in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

Learn Amazon Simple Queue Service (Amazon SQS) in lessons

18 short lessons on Amazon Simple Queue Service (Amazon SQS) in 7 certification courses.

and 12 more lessons

Open the lessons

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.