Here, we will create an understanding of SQS.

  •  Reliable, scalable, hosted queue service for sending, storing and retrieving messages.
  • Queue act as a buffer between sender and receiver.
  • 256kb message, >256kb managed using SQS extended client library which uses S3, deliver message atleast once, not FIFO, can be create in
  • any region, retained for 14 days
  • can be sent and read simultaneously
  • long polling reduces frequent polling (wait 20 secs if queue empty)
  • First 1 million request free, $0.50 next 1 million + data transfer charges, SQS queues can be scaled.
  • Amazon SQS Architectures
    • Priority (2 queues High/Low)
    • Fanout (SNS topic/multiple SQS queues for parallel processing)
  • This supports both standard and FIFO queues.
  • Standard Queue
    • Unlimited Throughput
    • At-Least-Once Delivery
    • Best-Effort Ordering
  • FIFO Queue
    • High Throughput
    • Exactly-Once Processing
    • First-In-First-Out Delivery

Distributed Queues

3 parts in a distributed messaging system

  • the components of distributed system
  • queue (distributed on Amazon SQS servers),
  • messages in the queue.

Below, system send messages to queue and receive messages from queue. The queue (holds messages A through E) redundantly stores the messages across multiple Amazon SQS servers.

Understanding SQS

Message Lifecycle

Understanding SQS
  1. A producer or component 1 sends message A to a queue, and the message distribute across the Amazon SQS servers redundantly.
  2. When a consumer or component 2 is ready to process messages, it consumes messages from the queue, and message A returns. While message A is being processed, it remains in the queue and isn’t returned to subsequent receive requests for the duration of the visibility timeout.
  3. The consumer or component 2 deletes message A from the queue to prevent the message from being received and processed again when the visibility timeout expires.

Best Practices

  • Processing Messages in a Timely Manner
  • Handling Request Errors
  • Setting Up Long Polling
  • Capturing Problematic Messages
  • Setting Up Dead-Letter Queue Retention
  • Avoiding Inconsistent Message Processing
  • Implementing Request-Response Systems

To reduce costs, batch message actions:

  • use the Amazon SQS batch API actions
  • use long polling together with buffered asynchronous client.
Menu