Skip to content

Instantly share code, notes, and snippets.

@MirzaLeka
Last active January 29, 2023 23:05
Show Gist options
  • Save MirzaLeka/d2246c249c85ac83d356afc87923d353 to your computer and use it in GitHub Desktop.
Save MirzaLeka/d2246c249c85ac83d356afc87923d353 to your computer and use it in GitHub Desktop.
AWS SQS Guide

AWS SQS Guide

Amazon Simple Queue Service (SQS) lets you send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available.

Messages stored in SQS can be pulled out by other services such as EC2, Lambda, etc. Upon pulling, message is deleted from the queue.

image

Two types of queues:

  • Standard Queue
  • FIFO Queue (First In, First Out)

  • Standard queues provide higher throughput, are cheaper, but the order of messages is not preserved. Message can be recieved and processed multiple times by the polling thread (AWS service).
  • FIFO queues ensure the order of messages, but throughput is much lower. Message will be received only once.

Creating Queues

Every queue comes with a very-detailed configuration.

image

  • Visibility timeout - is the period in which the message cannot be processed by any other consumer (0 - 12h)
  • Message rentention period - how many days is message stored in queue (1 to 14d)
  • Delivery delay - how long until message appears in the queue (1 - 15s)
  • Maximum message size - data size (1b - 256kb)

image

Other rules include:

  • Access policy (who can make use of the queue)
  • Encryption
  • Dead Letter Queue (DLQ)
  • Redrive Policy
  • Tags

Dead Letter Queue (DLQ) - is a special queue where all of the failed messages can be stored. After a message fails to be processed several times (x times specified), you can store failed message in DLQ for later processing. Then you can create an alert system that notifies us whenever there is something stored in DLQ to retrieve it back to SQS (using Redrive allow policy on SQS specified in the SQS configuration). The DLQ is disabled by default.

Queue Dashboard

Upon creating queue you'll land on the dashboard where you can see name of the queue, ARN, URL and other details.

image

Clicking on the Send and receive messages button, we can insert a message directly in a queue.

Send Messages

To a send message you need to set message body field, e.g.:

{
  "message": "Hello World!"
}

After that you can also set Delivery delay (that is 0 by default) as well as message atrributes (up to 10) that can be used to uniquely identify messages.

image

By clicking on the orange "Send message" button, a new message will appear in the Queue avaialble messages count will increase.

Messages available
1

Learn More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment