What is SQS
Amazon Simple Queue Service – A Fully managed message queuing web service that access to message queues that store messages waiting to be processed. With Amazon SQS, you can quickly build message queuing applications that can run on any computer.
Amazon Simple Queue Service – A Fully managed message queuing web service that access to message queues that store messages waiting to be processed. With Amazon SQS, you can quickly build message queuing applications that can run on any computer.
It just saves a simple text message. Each message can
be upto 256 KB. Gurantees delivery of message atleast once but does not gurante the order and does not
gurantee for duplicates
Worker Instance: If message sent to SQS contains instruction. Then it is
call a worker instance (EC2)
Eg: If it is to process an image in S3 and worker instance permfors actions based on instruction.
Parallel Processing - Auto scaling based on the number of messages.
Eg: Queue is too large then we can fire up more instances faster way to process also HA if components fails
Messages become unavailable after the timeout or once
if the message is processed. Allows the creation of distributed/decoupled
application components
Decoupled - If one component fails it does not affect
other component.
Features
a) Fast, Reliable, Highly-scalable & Fully managed message queuing service
b) High Throughput: Standard queues have nearly-unlimited transactions per second (TPS).
c) At-Least-Once Delivery:
d) Best-Effort Ordering
e) Limited Throughput: 300 transactions per second (TPS).
How to Connect
To connect to SQS we need Key and Secret access key
To Read and write the queue – Use URL
Limits
a) Retention Period - 0 to 14 Days. Default 4 days.
b) Message size - 256 KB
c) Queue will be
considered as active upto 6 hous after last activity
d) Visiblity timeout -
Maximum 12 hours , Default 30 Seconds
e) Delay Second - 0 to
15 mins
g) Maximum Long Poll timeout - 20 Seconds
Monitoring
No Detailed Monitoring, only Basic (5 Minutes)
Cloudtrail can be
enabled for create/delete queue
(i) Types of Queue
a) Standard (Available in all regions)
b) FIFO (First in First out) ( Available
only in USW and USE )
Exactly-Once Processing: A message is guaranteed to be delivered at least once, but all duplicates of the message are removed.
Standard queues provide at-least-once delivery, which means that each message is delivered at least once.
Standard queues provide at-least-once delivery, which means that each message is delivered at least once.
FIFO queues provide exactly-once processing, which means that
each message is delivered once and remains available until a consumer processes
it and deletes it. Duplicates are not introduced into the queue. The order in which messages are sent and received is strictly preserved.
(ii) Types of Polling
a) Long polling
b) Short polling
a) Long polling
b) Short polling
Long Polling - Benefit is reduction of the number of empty responses, when there is no messages available to return. In reply to a ReceiveMessage request sent to an Amazon SQS queue. It allows SQS to wait until a message is available in the queue before sending a response. So unless the connection times out, the response to the RecieveMessage request will contain atleast one of the available message
Long polling requests allow your queue consumers to
receive messages as soon as they arrive in your queue, while reducing the
number of empty ReceiveMessageResponses you encounter. , SQS long polling
results in higher performance at reduced cost for the majority of use cases.
However, if your application is written to expect an immediate response from a
ReceiveMessage call, you may not be able to take advantage of long polling
without some application modifications. For example, if your application has a
single thread polling multiple queues, switching from short polling to long
polling will likely not work, as the single thread will wait for the long poll
timeout on any empty queues, delaying the processing of any queues which may
contain messages. In such an application, it is recommended that a single
thread be used to process only one queue, allowing for the application to take
advantage of the benefits SQS long polling provides.
The following
table lists the API actions to use.
Short Polling
WaitTimeSeconds parameter - ReceiveMessage
ReceiveMessageWaitTimeSeconds
attribute CreateQueue, SetQueueAttributes
Short polling occurs when the WaitTimeSeconds
parameter of a ReceiveMessage call is set to 0 in one of two ways:
The ReceiveMessage call sets WaitTimeSeconds to 0.
The ReceiveMessage call doesn’t set WaitTimeSeconds
and the queue attribute ReceiveMessageWaitTimeSeconds is set to 0.
Note
For the WaitTimeSeconds parameter of ReceiveMessage, a
value set between 1 and 20 has priority over any value set for the queue
attribute ReceiveMessageWaitTimeSeconds.
Other Options
a) Default Visibility Timeout
a) Default Visibility Timeout
The length of time (in
seconds) that a message received from a queue will be invisible to other
receiving components. 30 seconds Value must be between 0 seconds and 12 hours.
b) Message Retention Period
The amount of time that
Amazon SQS will retain a message if it does not get deleted. 4 days Value must be between 1
minute and 14 days.
c) Maximum Message Size Value must be between 1 and 256 KB.
d) Delivery Delay The amount of
time to delay the first delivery of all messages added to this queue.0 seconds.Value must be
between 0 seconds and 15 minutes.
e) Receive Message Wait Time
The maximum amount of time
that a long polling receive call will wait for a message to become available
before returning an empty response. Value must be between 0 and 20 seconds.
f) Delay Queues - delay
queue allows the user to set a default delay on a queue such that delivery of
all messages queued is postponed for that time duration
g) Dead Letter Queues - is a queue for messages that were not able to be processed after a maximum number of attempts
Note : You must use a FIFO dead letter queue with a FIFO queue. (Similarly, you can use only a standard dead letter queue with a standard queue.)
Some More information about SQS
1) All messages have a unique ID that SQS returns when the message is delivered.
2) Both empty and non -empty queue can be deleted
No comments:
Post a Comment