Simple Queue Service (SQS)

  1. AWS SQS is a web service that provides us with a message queue on the cloud to which a sender process (not humans) can send a message and a reader process (not humans) can retrieve/process/delete the message.
    1. So message queue is basically a temporary repository of messages on the AWS cloud.
  2. SQS is asynchronous. Processes are  decoupled (or loosely coupled), distributed, hence highly elastic and scalable.
  3. SQS is pull based system (unlike SNS which is push based). One or more reader programs/lambdas/EC2s can pull messages. You can setup auto scaling to add/remove pulling EC2 instances based on the size the queue.
  4. Messages can be 256 KB max. Text only. Billed in 64 KB chunks.  You can ASCII encode if you need to send binary files.
  5. Two types of queues:
    1. Standard queues:
      1. No order is maintained.
      2. Messages are guaranteed to be sent at-least once. Some rare occasions they are sent twice or more. You need to architect keeping this in mind.
    2. FIFO queues:
      1. Order of messages is maintained.
      2. Messages are guaranteed to be sent only once.
      3. Multiple ordered messages groups can be hosted in a single queue.
      4. Max 300 transactions per sec.
  6. Messages can be kept in the queue from duration of 1  min to 14 days max. Default is 4 days.
  7. Visibility Timeout (VT) of a message is the amount of time it will be invisible in the queue after a reader pulls that message.
    1. Max visibility timeout is 12 hours.
    2. Default visibility timeout is 30 sec
    3. After timeout expires, the message will be automatically visible again in the queue. So its the responsibility of the reader to delete the message after processing.
    4. Also make sure message processing is finished before the VT or else you as an architect need to increase the visibility timeout.
  8. Two types of polling possible by the reader
    1. Short polling returns immediately. So it could be expensive if the queue is sparse.
    2. Long polling returns only when a message is available in the queue or the long polling timeout (min 1 sec to max 20 sec) whichever is earliest.
  9. Custom SQS Policy can be used to allow access to queues across accounts
    1. If you want to allow Amazon SQS access based only on an AWS account ID and basic permissions (such as for SendMessage or ReceiveMessage), you don’t need to write your own policies. You can just use the Amazon SQS AddPermission action.
    2. If you want to explicitly deny or allow access based on more specific conditions (such as the time the request comes in or the IP address of the requester), you need to write your own Amazon SQS policies and upload them to the AWS system using the Amazon SQS SetQueueAttributes action.
  10. Single request can have 1 to 10 messages with a maximum 256KB payload
  11. Cost: First 1 million request ares free, then $0.50 per million req.
  12. Priority based Design – Create 2 queues, one for higher priority (Eg: Paid Customers)  and other for lower priority (free users). Lets EC2 read priority queues first and process then move on to low priority queue.
<<< AWS Simple Notification Service (SNS)Simple Workflow Service (SWF) >>>
Copyright 2005-2016 KnowledgeHills. Privacy Policy. Contact .