Amazon Simple Queue Service (SQS)

Amazon Simple Queue Service (SQS)

·

10 min read

What is Amazon SQS?

Amazon Simple Queue Service (SQS) is a secure, durable, fully managed, and available hosted queue that offers to integrate and decouple distributed software systems and components by allowing transmitting data between distributed application components. SQS eliminates the complexity and burden associated with managing and operating message-oriented middleware and empowers developers to focus on differentiating work. Using SQS, messages can be sent, stored, and received between software components at any volume, without losing messages or requiring other services to be available.

image1.png

image2.png

Use cases-Application integration, Allocation of tasks to multiple worker nodes, Decouple live user requests from intensive background work, Decoupling microservices, Batch messages for future processing.

An Amazon SQS message has three basic states:

  • Sent to a queue by a producer
  • Received from the queue by a consumer and
  • Deleted from the queue.

Between state 1 and state 2, the message is stored in a queue and available for use while in-between state 2 and state 3, the message is in flight and not available for use for the other consumers.

When a consumer receives and processes a message from a queue, Amazon SQS doesn’t delete the message automatically because SQS is a part of a distributed system, there’s no guarantee that the consumer receives the message (for example, due to a connectivity issue, or due to an issue in the consumer application). This needs to be done by the event handler function at the consumer’s side after receiving and processing the message. If the message is not deleted during the defined period (called visibility timeout), the message becomes again visible for the other consumers.

Benefits of Amazon SQS

- Administrative overhead

It eliminates administrative overhead and AWS SQS will manage all the operations that are currently underway and infrastructure which is required to scale and run a message queuing. There is no requirement to install and configure messaging software as well as maintenance of infrastructure.

- Security

Amazon SQS can be used to exchange sensitive data between applications using server-side secret writing (SSE) that offers to transmit sensitive data by protecting the contents of messages in queues using keys managed in AWS Key Management Service (AWS KMS). It also allows controlling who can send messages to and receive messages from an Amazon SQS queue.

- Durability

To ensure the safety of your messages, Amazon SQS stores them on multiple servers though only for a limited. (Max.- 14 days)

- Availability

Amazon SQS stores data on different servers and uses redundant infrastructure to provide highly-concurrent access to messages.

- Scalability

Amazon SQS allows to dynamically increase read throughput by scaling the number of tasks reading from a queue and requires no pre-provisioning or scale-out of AWS resources. It easily scales to handle a large volume of messages, without user intervention. SQS buffers requests to transparently handle an increase in load.

- Reliability

It locks your messages during processing so that a message is consumed only once by a single consumer. It also enables multiple producers can send and multiple consumers can receive messages at the same time.

- Customization

Amazon SQS allows customization in multiple ways, from modifying the queue attributes to integrate with other AWS services in an order to build scalable and more flexible applications. It is compatible with other Amazon Web Services, including Amazon Relational Database Service, Amazon Elastic Compute Cloud, and Amazon Simple Storage Service.

Features of Amazon SQS

- No Data Loss

SQS ensures that the messages sent are not lost and secure. Hence, it stores them on multiple standard queues.

- Confidential data

SSE (server-side encryption) allows transmission of highly confidential and sensitive data by offering protection to the messages present in the queues with the help of Amazon key management service.

- Each Request is handled independently

In SQS, every buffered request is processed independently ie. each request is scaled transparently to handle the increase in load without any explicit instructions.

- Message Locking

SQS locks the user messages when it is being processed so that various producers can send messages to various receivers and receivers could receive messages from multiple recipients at the same time.

- Two queue types

Amazon SQS offers two types of queues - standard and FIFO queue for different application requirements.

- Unlimited queues and messages

A user can create unlimited SQS queues processing an unlimited number of messages in any region.

- Payload size

Messages payload can be of a maximum 256Kb size in any format. Each 64KB of a payload is considered as 1 request, hence, a single API call with 256KB payload is considered as 4 requests. If a user wants to send a message having a size larger than 256KB, he can use Amazon SQS extended client library for Java.

RedBus Case Study

redBus_logo_red.png

redBus is an Indian travel agency that specializes in bus travel throughout India by selling bus tickets throughout the country. Tickets are purchased through the company’s Website or through the Web services of its agents and partners. The company also offers software, on a Software as a Service (SaaS) basis, which gives bus operators the option of handling their own ticketing and managing their own inventories. To date, the company says they have sold over 30 million bus tickets and has more than 1750 bus operators using the software to manage their operations.

The company previously ran its operations from a traditional data centre by purchasing and renting its systems and infrastructure. In addition to the expense, several logistical problems evolved from this arrangement. The biggest problem was that the infrastructure could not effectively handle processing fluctuations, which had a negative impact on productivity. Additionally, the procurement of servers or upgrading the server configuration was an extremely time-consuming endeavour. Over time, redBus realized that a better solution was imperative—a solution that offered scalability to handle the company’s processing fluctuations. redBus looked to Amazon Web Services (AWS) for a solution.

" With the time savings that the IT and development staffs obtain from the AWS solution, AWS gives us an overall cost-benefit of about 30-40%.” Charan Padmaraju Chief Technology Officer, redBus

Since migrating to AWS, redBus has seen measurable improvements in the bottom line. Padmaraju says, “By scaling up and down dynamically based on the load, we maintain performance as well as minimize cost. With the time savings that the IT and development staffs obtain from the AWS solution, AWS gives us an overall cost-benefit of about 30-40%.” He adds, “By hosting at [the AWS Asia Pacific (Singapore) region], redBus.in gained significantly in terms of website performance by way of reduced latency (about 4x). This is a great advantage when the customers are from India.”

Of the many excellent characteristics of AWS, perhaps the most significant to redBus is the ability to “instantly replicate the whole setup on-demand for testing by creating and destroying instances on demand for experimentation, thereby reducing the time to market.” Less time to market translates to increased profitability and success.

The travel agency anticipates expanding the AWS solution to include Amazon Simple Notification Service (Amazon SNS) and Amazon Simple Queue Service (Amazon SQS) for monitoring, alerts, and intercommunication. “Amazon SQS is an especially good solution for enabling messaging between external applications and our applications,” says Padmaraju.

Since joining forces with AWS, redBus has gained the freedom to experiment on new solutions and applications at minimal cost, increased the efficiency of its operations, and improved its profitability.