Link Search Menu Expand Document

Image from @awsgeek

Simple Queue Service

SQS Basics

  • πŸ“’ Homepage βˆ™ Documentation βˆ™ FAQ βˆ™ Pricing
  • SQS is a highly scalable, fully managed message queuing service from AWS.
  • SQS supports the pull model, where the producers queue the messages, and the consumers pull messages off the queue.
  • SQS provides a message visibility timeout, during which the message being processed will not be delivered to other consumers. If the consumer does not delete the message after processing, the message becomes available to other consumers upon reaching the message visibility timeout. This parameter is called VisibilityTimeout.
  • Each message can have up to 10 custom fields, or attributes.
  • SQS allows producers to set up to 15 minutes of delay before the messages are delivered to the consumers. This parameter is called DelaySeconds.
  • There are two types of queues supported by SQS -
    • Standard Queues
      • Guarantee at least once delivery of the messages.
      • Do not retain the order of delivery of the messages.
    • FIFO Queues
      • Guarantee only once delivery of the messages
      • Guarantee the order of the delivery of the messages
  • SQS supports fine grained access to various API calls and Queues via IAM policies.
  • The messages that fail to process can be put in a dead letter queue.

SQS Alternatives and Lock-In

SQS Tips

  • SNS can be used in combination of SQS to build a β€œfan out” mechanism by having an SQS Queue subscribe to the SNS topic.
  • SQS supports encryption using AWS KMS.
  • Cloudwatch alarms can be creating using various SQS metrics to trigger autoscaling actions and/or notifications.

SQS Gotchas and Limitations

  • πŸ”Έ SQS does not have a VPC endpoint (unlike S3 and DynamoDB), so SQS will need to be accessed using public SQS API endpoints.
  • πŸ”Έ FIFO Queues are limited to 300 API calls per second.
  • πŸ”Έ FIFO Queues cannot subscribe to an SNS topic.
  • πŸ”Έ Standard Queues can deliver duplicate messages regardless of the visibility window. If only-once delivery is your only choice, then use FIFO queues, or build an additional layer to de-dupe the messages.
  • πŸ”Έ You can send/receive messages in batch, however, there can only be maximum of 10 messages in a batch.