AWS Simple Queue Service(SQS) and Simple Notification Service (SNS)

AWS Simple Queue Service(SQS) and Simple Notification Service (SNS)

When we are building an Application, different components are interdependent on other components, When one Component fails others are also affected by it. So How does AWS offers service to solve these issues using AWS SQS and SNS, Let's see in detail.



Before Learning about SQS and SNS there are some cloud concepts that we need to know. They are differences between loosely coupled and tightly coupled architectures, we will be also learning about Monolithic and Microservices.

Tightly and Loosely Coupled Architectures

                To understand this topic we shall consider an example, let's consider we are making a full-stack web application with all user interactions and database management, and it's an online retail website. Now for the proper working of the website both the database and application should run properly, In other words, we can say that " The working of one component will decide the working of another component". In our example the database and application are dependent, This type of architecture is known as tightly coupled architecture, where if one component fails it might affect the working of another component and sometimes can affect the whole system. If the database of the retail shop stops working then the whole website is of no use. So it is important to make infrastructure as loosely as possible.

                Not only in a web application or software development, tightly coupled components can be seen in many infrastructures and in the AWS cloud also. But AWS has made a few services that are useful to make the architecture loosely coupled up to a certain extent, After learning about tightly and loosely coupled architecture there is one more concept called monolithic applications and microservices applications we are important in understanding the types of applications

Monolithic Applications and Microservices

                As we talked applications are made of different components and if the components are interdependent on other components then they are called tightly coupled components, Monolithic applications are tightly coupled applications. In this approach of making applications, there are many different components, which are affected by the working of other components. If one component stops working it will affect the whole system. Monolithic applications are usually large applications where changing one component requires updating all other components. But as they are dependent on each other deploying the whole application is easier than Microservices. But one major disadvantage of This architecture is if we want to scale the application we need to scale every component instead of scaling the required component which will increase the cost.

                Microservices are the opposite of Monolithic, here the components are decoupled or loosely coupled from others. It's like breaking big applications into small components or services, which are independent and do not require additional requirements. All the microservices have their own functionalities and databases. We can understand individual components more easily and the scalability of the application also increases. The disadvantage of using Microservices is that the complexity of the application increases, as we should check whether each individual service is running properly or not, Connecting the components and getting information from different services is also difficult.

Now We learned about Tightly and Loosely Coupled Architecture let's see how AWS Overcomes this Problem using SQS and SNS services.

AWS Simple Queue Service (SQS)

                In an infrastructure when one component is sending information to another component, if the other components fail it might cause errors in the main component also, so to solve this AWS introduced SQS, where the messages are stored in a queue and the components can read the information from it. Let's understand this with a simple example. Suppose you are in a hotel and you have ordered some food, the waiter has taken the information about the food, But when he reaches near the chef if the chef is busy with some other work, etc. then sometimes the waiter may drop your request and move to next customer, which is a tightly coupled architecture. To solve this the simple solution may be keeping the orders on a board or list from which the chef can see and make dishes. The board or list is the same as the Queue in AWS. If there are different instances like EC2 which are communicating with each other and if one instance is terminated because of some problem, all the data will be saved in the queue until a new instance is initialized, after that again there will be the proper working of instances, hence we are successful in achieving loosely coupled architectures.



                We can retrieve store and send messages from the Simple Queue service. One or more applications can send information into a queue and one more application can retrieve the information. This is mostly used in distributed applications. The data will be stored in the queue until an application retrieves it.

AWS Simple Notification Service (SNS)

                AWS SNS is similar to the publisher/subscriber model, if you don't know this model it is similar to a youtube subscription, whenever your subscribed channel uploads a new video you will get a notification in the same way, whenever the publisher publishes new information the subscribers are notified about it. For this they need to subscribe to the publisher then only they can receive notifications. The SNS receivers can be any applications like web apps, AWS lambada, or even EC2 instances. Whenever a new topic is released sending on a copy will be sent to the whole network which makes the work easier, and also we can subscribe to multiple topics.




                This information can be anything from a program to emails, SMS, and even messages. We can also use Serverless computing like AWS Lambda to trigger functions based on the notifications, here the end-user application will be a lambda function and performs a specific task upon receiving the notification. Learn more about AWS Lambda here AWS EC2 Vs AWS Lambda

Post a Comment

Previous Post Next Post