Wednesday, May 24, 2017

SQS - Simple Queue Service

SQS : Simple Queue Service
   
  •     It s web service that gives you access to a message queue that can be used to store messages while waiting for a computer to process them.
  •     It is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the applications generates to be consumed by another component. A queue is a temporary repository for messages that are awaiting processing.
  •     Decouple the components of an application so they can run independently, amazon SQS easing the message management between components. Any component of a distributed application can store messages in a fail-safe queue.
  •     Messages can contain up to 256KB of text in any format. Any component can later retrieve messages programmatically using the Amazon SQS API.
   
    Issue SQS resolves: Producer is producing work faster than the consumer can process it, or if the producer and consumer are intermittently connected to the N/W.
   
    With SQS service ensures delivery of a message atleast once and supports multiple readers and writers interacting with the same queue.
   
    A single queue can be used by simultaneously by many distributed application components, with no need for the components to coordinate with each other to share the queue.
   
    It is engineered to be always available and deliver messages.
   
    SQS TradeOff : SQS doesnt guarantee first in first out delivery of messages. For many distributed applications, each message can stand on its own and wait as long as the messages are delivered, the order is not important.

    If the system requires order to be preserved, we can place sequencing information in each message, so that we can reorder the messages when the queue returns them.
   
    The visibility time out clock starts only when the application server has picked up the service atleast once. If the server goes offline the visibility timeout also expires and the message will still be available for another application server.
   
    Only when the message is deleted from the queue thats when the message is complete.
   
    If the messages have gone close to the threshold, it will make more application servers spin to complete the messages. SQS with Autoscaling is VERY POWERFUL.
   
    Exam Q's :
  1.     No First In First Out
  2.     12 hours visibility timeout by default.
  3.     SQS is engineered to provide the message at least once. We need to make sure as developer   so that multiple messages will not give errors/inconsistencies.
  4.     256KB message now available
  5.     Billed at 64KB chunks.
  6.     A 256KB is 4 chunks( 4* 64KB).
   
    Pricing:
  1.     First 1 million SQS requests per month are free.
  2.     $0.50 per million SQS requests per month there after ($0.00000050 per SQS request).
  3.     A single request can have 1 to 10 messages upto a maximum total payload of 256KB.
  4.     Even a single API call for 256KB is billed 4 times per 64KB.

No comments:

Post a Comment