fbpx
bg_image
Comments Off on Serverless Powerhouse: SNS, SQS & Lambda for Scalability
Posted By

Syed Muhammad Kashif

Avatar Of Syed Muhammad Kashif

What are SNS, SQS, and Lambda, and how are they utilized?

Simple Notification Service (SNS), Simple Queue Service (SQS) and Lambda are powerful AWS services that can be used together to build scalable and reliable microservices-based applications.

These three services can be used together to build a variety of serverless applications. For example, you could use them to build a real-time notification system, a queue-based workflow system, or a data processing pipeline.

SNS, SQS, and Lambda for Asynchronous Microservice Processing

SNS, SQS, and Lambda can be used to implement a fanout scenario in a microservices architecture. SNS is a publish-subscribe messaging service that allows you to decouple your microservices and send messages to them asynchronously. SQS is a message queuing service that provides a durable and reliable way to store and process messages.

Fanout scenario publishes a single message to an SNS topic and then distributed to multiple SQS queues. This allows you to process the message in parallel across multiple microservices, which can improve the scalability and performance of your application.

Example

E-commerce websites can improve the scalability and performance of their order processing systems by using Amazon SNS, SQS, and lambda (Simple Notification Service (SNS), Amazon Simple Queue Service (SQS), and AWS Lambda) to process bulk orders in parallel.

When a customer places a bulk order, the website publishes a message to an SNS topic. The message contains information about the order, such as the customer's name, address, and the products they ordered.

The SNS topic is subscribed to by multiple SQS queues, each of which is responsible for processing a different part of the order. For example, one queue might be responsible for sending an order confirmation email to the customer, another queue might be responsible for updating the inventory system, and another queue might be responsible for shipping the order.

The SQS queues are then processed by Lambda functions. Each Lambda function is responsible for performing a specific task, such as sending an email, updating the inventory, or shipping the order.

Sns, Sqs, And Lambda Based On Aws Services, Serverless Application

How to Use SNS, SQS, and Lambda for Asynchronous Microservice Processing

"Man who chooses to enjoy a pleasure that has no annoying consequences"

Repeat the above steps for additional SQS queues.

Add Environment Variable In Lambda Function Code Picture - Sns, Sqs, And Lambda Based On Aws Services, Serverless Application

Open the Amazon SNS Topic console.

Running And Verifying Sns Sqs Setup -Sns, Sqs, And Lambda Based On Aws Services, Serverless Application

For confirmation, the message was received in SQS OR not, Open the Amazon SQS Queue console.

Amazon Sqs Queue Console - Received Message- Ssns, Sqs, And Lambda Based On Aws Services, Serverless Application

Repeat the same Process for Checking another SQS Queue.
For reading that message details open the Lambda function console.

Reading That Message Details Open The Lambda Function Console-Sns, Sqs, And Lambda Based On Aws Services, Serverless Application

Glossary

SNS is a publish-subscribe messaging service that enables you to decouple microservices, distributed systems, and serverless applications. SNS publishes messages to topics, and subscribers receive messages from topics. SNS supports a variety of message delivery protocols, including HTTP, HTTPS, email, SMS, and mobile push notifications.

It is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS offers a simple, durable, and highly scalable way to buffer messages between applications and components. SQS supports first-in-first-out (FIFO) delivery to ensure that messages are processed in the order that they were received.

Lambda is a serverless compute service that enables you to run code without provisioning or managing servers. Lambda triggers your code in response to events generated by AWS services, such as SNS notifications, SQS messages, and changes to DynamoDB tables. Lambda automatically scales your code based on demand, so you can focus on building applications without worrying about managing infrastructure.