Amazon SQS – Standard Queue Overview
The Standard
Queue is the default queue type in Amazon Simple Queue Service (SQS).
It's designed for high throughput, best-effort
ordering, and at-least-once delivery.
This type of queue is ideal when occasional duplicate messages and out-of-order message processing are acceptable.
Amazon SQS - Standard Queue is fully a managed service, that is used to decouple applications.
Amazon SQS - Standard Queue has unlimited throughput, with unlimited number of messages can be sent and the queue can have unlimited messages too.
Key Features of SQS Standard Queue
Feature |
Description |
Delivery Model |
At-least-once delivery – a message may be delivered more than once(can have duplicate messages). |
Message Ordering |
Best-effort ordering – messages may not be received in the exact order they
were sent. |
Throughput |
Unlimited transactions per second (TPS). |
Visibility Timeout |
Temporarily hides messages after a
consumer retrieves them. |
Message Size |
Up to 256 KB of text data
(can be extended via S3 for larger payloads). |
Retention |
Messages can be retained from 1
minute to 14 days (default: 4 days). |
Security |
Supports encryption (SSE
via AWS KMS) and access control via IAM policies. |
Retries & DLQ |
Supports retry policies and
dead-letter queues (DLQs) for failed messages. |
Long Polling |
Reduces empty responses and cost
by waiting for messages up to 20 seconds. |
How Standard Queues Work
- Producer
sends a message to the Standard Queue.
- The message is stored redundantly across
multiple AWS servers.
- A consumer (worker or application) polls the
queue and receives messages.
- The message is invisible during processing
(visibility timeout).
- After processing, the consumer deletes the
message.
- If the message isn't deleted in time, it becomes visible
again for reprocessing.
Use Cases for Standard Queues
- High-throughput applications
- Real-time user activity tracking
- Distributed systems with independent processing
- Order-insensitive task queues (e.g., image resizing,
logging)
- Decoupling microservices in an event-driven
architecture
Example of how twtech Sends and Receive (Using AWS CLI)
# bash
#
Create a Standard Queue
aws sqs create-queue --queue-name twtech-StandardQueue
#
Send a message
aws
sqs send-message \
--queue-url https://sqs.us-east-2.amazonaws.com/1234567xxxx/twtech-StandardQueue
\
--message-body "Hello twtech-team, SQS!"
#
Receive a message
aws
sqs receive-message \
--queue-url https://sqs.us-east-2.amazonaws.com/1234567xxxx/twtech-StandardQueue
Here's twtech step-by-step guide to
create a Standard Queue in the AWS Management Console using Amazon SQS:
Step-by-Step: Create a Standard Queue
1. Sign in to the AWS Console
·
Go to: https://console.aws.amazon.com/sqs
· twtech Makes sure it is in the correct AWS Region (top-right
corner).
2. Open the Amazon SQS Console
·
From the Services menu, search for SQS and select it.
3. Create Queue
·
Click on the “Create queue” button.
4. Choose Queue Type
·
Choose Standard
Queue (default selection).
o Standard → High
throughput, at-least-once delivery
o Leave FIFO Queue unchecked
5. Configure Queue Name
·
Enter a Queue
name, for example: twtech-StandardQueue
.
6. Configure Optional Settings
twtech can leave most defaults, or customize if
needed:
·
Visibility
timeout: How long a message remains invisible after being
received (default: 30 sec).
·
Message
retention: How long messages stay in the queue (default: 4
days).
·
Delivery
delay: Delay all messages (optional).
·
Maximum
message size: Default is 256 KB.
·
Receive
message wait time: Set to 20 seconds for long polling
(recommended).
7. Access Policy (Permissions)
·
Choose one of the options:
o Basic (only the queue
owner can send/receive)
o Advanced (for custom IAM
policies)
· twtech can allow other AWS accounts or services
(like Lambda) to access the queue here.
8. Encryption (Optional)
·
Choose SSE
(server-side encryption) with AWS KMS if you need to encrypt
messages.
9. Dead-letter Queue (Optional)
· twtech can configure a DLQ to handle failed message
processing.
·
Skip or configure later if not needed now.
10. Click “Create Queue”
· twtech will be taken to the queue’s dashboard with
details, monitoring, and test tools.
Testing twtech Queue
After creation, twtech can:
·
Send
a test message from the “Send
and receive messages” tab.
·
Receive/delete
messages to simulate a consumer.
Here's twtech complete Python example
using Boto3 to interact with Amazon SQS (Standard Queue) — including
creating a queue, sending a message, receiving it, and deleting it.
Pre-requisites
- Install Boto3
(if not already installed):
# bash
pip
install boto3
- Configure AWS Credentials:
# bash
aws
configure
Provide your AWS Access Key, Secret
Key, Region (e.g., us-east-2), and output format (e.g., json).
Python Code: Create, Send, Receive, Delete
Message
# python
import boto3
#
Create an SQS client
sqs = boto3.client('sqs')
#
1. Create a Standard Queue
response
= sqs.create_queue(
QueueName='twtech-StandardQueue',
Attributes={
'DelaySeconds': '0',
'MessageRetentionPeriod': '345600' # 4 days in seconds
}
)
queue_url
= response['QueueUrl']
print(f"Queue created: {queue_url}")
#
2. Send a Message to the Queue
send_response
= sqs.send_message(
QueueUrl=queue_url,
MessageBody='Hello from Boto3!',
MessageAttributes={
'Sender': {
'StringValue': 'twtech-PythonApp',
'DataType': 'String'
}
}
)
print(f"Message sent. ID: {send_response['MessageId']}")
#
3. Receive the Message
receive_response
= sqs.receive_message(
QueueUrl=queue_url,
MaxNumberOfMessages=1,
WaitTimeSeconds=5, # Enable long polling
MessageAttributeNames=['All']
)
messages
= receive_response.get('Messages', [])
if
messages:
message = messages[0]
receipt_handle = message['ReceiptHandle']
print("Message received:")
print(f" Body: {message['Body']}")
print(f" Attributes: {message.get('MessageAttributes', {})}")
# 4. Delete the Message after processing
sqs.delete_message(
QueueUrl=queue_url,
ReceiptHandle=receipt_handle
)
print("Message deleted.")
else:
print("No messages received.")
Insights:
- create_queue()
will reuse an existing queue with the same name.
- MessageRetentionPeriod
controls how long a message is kept in the queue (up to 14 days).
- WaitTimeSeconds
in receive_message() enables long polling, reducing empty responses
and cost.
Here's twtech clear side-by-side
comparison of Amazon SQS – Standard Queue vs FIFO Queue, so anyone can
choose the right one based on the application's needs.
Amazon SQS: Standard Queue vs FIFO Queue
Feature |
Standard
Queue |
FIFO
Queue |
Delivery Guarantee |
At-least-once (duplicates possible) |
Exactly-once (no duplicates) |
Message Order |
Best-effort (unordered delivery) |
First-In-First-Out (strict ordering) |
Throughput |
High (unlimited TPS) |
Limited (up to 300 TPS
without batching, 3,000 TPS with batching) |
Duplicates |
Possible |
Not allowed |
Use Case |
High-throughput, unordered tasks
(e.g., logging, processing) |
Ordered, unique tasks (e.g.,
transactions, ledgers) |
Message Group ID |
Not required |
Required (used to maintain ordering) |
Deduplication ID |
Not used |
Required or auto-generated
(ensures no duplicate delivery) |
Queue Name Format |
Any name (e.g., MyQueue) |
Must end with .fifo (e.g., MyQueue.fifo) |
Supports Encryption, DLQ, IAM |
✅ Yes |
✅ Yes |
Batching Support |
✅ Yes (up to 10 messages) |
✅ Yes (up to 10 messages) |
Latency |
Typically lower due to less strict
guarantees |
Slightly higher due to ordering
& deduplication checks |
Use Standard Queue When:
- Message order doesn’t matter.
- twtech needs high throughput.
- Duplicate processing is acceptable or handled in
your app.
- Examples:
- Log aggregation
- Media processing pipelines
- User notifications
Use FIFO Queue When:
- Order matters
(e.g., financial transactions, event logs).
- twtech needs exactly-once delivery.
- Examples:
- Banking systems
- Inventory/order processing
- Workflow automation
Sample FIFO Queue Creation in Python (Boto3)
# python
response
= sqs.create_queue(
QueueName='twtech-FIFOQueue.fifo',
Attributes={
'FifoQueue': 'true',
'ContentBasedDeduplication': 'true'
}
)
No comments:
Post a Comment