What is SQS(Simple Queue Service) How does it works?

Reading Time: 3 minutes


SQS(Simple Queue Service) is a pull notification platform. SQS is a fast, reliable, fully managed message queue service as it is a web service that gives you access to a message queue that store messages waiting to be processed as it offers a reliable highly scalable hosted queue for storing message between servers.

It allows for the decoupling of application components such that failure in one component does not cause a bigger problem to application functionality.

Using an SQS you no longer need a highly available message cluster or the burden of running it.

You can delete all the messages in the SQS queue without deleting the SQS queue itself.

Types of Queue:- There are two types of Queue

Standard Queue:-

  • High (Unlimited ) Throughput.
  • At least one delivery.
  • Duplicacy is possible.
  • Best effort ordering.

FIFO Queue:-

  • Limited Throughput (300 TPS)
  • Exactly one processing
  • Duplicacy is not possible
  • Strict ordering -> First in – First Out
  • FIFO Queues is limited to 300 Transaction per second (TPS)

Types of Polling:-

Short Polling:

  • A request is returned instantly even if the queue is empty.
  • it does not wait for the message to appear in the queue.
  • It queries only a subset of available servers for message
  • Default by SQS
  • Receive wait time is set to 0.

Long Polling:-

Is referred to as regular/short polling. it uses fewer requests and request costs by:-

  • Eliminating false empty responses Quering all other servers
  • Reduce the number of empty responses by aligning amazon SQS to wait until the message is unavailable in the queue before sending the response unless the connection timeout (20 seconds).
  • Receive message wait time is set to a non-zero value (Max 20 Seconds).
  • Billing is the same for Both Polling.

SQS Pricing:-

The first 1 Million monthly requests are free after the pricing is according to the region

For eg ->

Standard queue – $040/million request

FIFO queue – $050/million request

How Amazon SQS Charges:

  • API Action:- Every amazon SQS action count as a request.
  • FIFO Request:- Api action for sending receiving, deleting, and changing the visibility of messages from FIFO queues are charged at FIFO rates.
  • Content of Request:- A single request can have from 1 to 10 messages.
  • Size of Payload:– Each 64 kb chunk of a payload is billed as 1 resource.

How does it work?

  • Go To console
  • Create queue -> For eg-> Test queue
  • Remains all things to Default
  • Create a message and send a message and there should be no delay time in the message.
  • Again go To service -> Search Compute -> SEARCH LAMBDA
  • Create Function -> USE A Blueprint Feature
  • Search SQS poller and select it.
  • SQS trigger -> Testqueqe ( Name of the queue)
  • Select batch size to 5
  • After all, these steps just scroll down and click on Create Function
  • A message will be displayed Congratulation it has been created
  • SQS should be enabled.

GO to AWS Management Console and search for Simple Queue Service.

Steps:- Name of the queue and all settings set as Default.
Step:- Create the message and Send a message.
Once you send the message then go to service and search lambda and then create a function and use A Blueprint( as it builds the sample code and configuration) after that search the SQS-poller ( An amazon SQS trigger that logs a message in a queue).

After it is created A message will be displayed as Congratulations Your Lmabds function Has been successfully created.

Once all the process is finished then there will be displayed 0 (zero) message as all the process is completed.