Cloud Computing #Day4
Tags: cloud, aws, microservices, serverless
Published: 2022-08-08 05:58:10

 In this article I will try to quickly cover the Amazon Messaging and Queuing services, and explore the lands of a few more additional services.
 
### The Flaw:
 
 In the process of accepting instructions or requirements to passing the requirements to the server both the systems will have to be on sync. At some point of time if the synchronisation is affected due to any unavoidable reason, such as the server is down the whole process stops and cannot proceed further. A much better process would be to introduce some sort of buffer or queue into the system. Hence the server or instance instead of handing the instructions directly would follow some sort of buffer, like an order board in a restaurant and the chef being the instance.  
> <strong>The idea of placing messages into a buffer is called messaging and queuing.</strong>  
 


 ![image](https://user-images.githubusercontent.com/88903134/183239065-f1054a9e-e0ec-4b2c-903e-b95513f040e6.png)

 
 This is where AWS introduced a message queue. Messages are sent into the queue by Application A and they are processed by Application B. If Application B fails, Application A doesn't experience any disruption. Messages being sent can still be sent to the queue and will remain there until they are eventually processed. <strong>They are loosely coupled.</strong> This is what AWS aims to achieve with its architectures. And eventually brings me to two AWS services that can assist in this regard:
 - <strong>Amazon Simple Queue Service or SQS</strong>
 - <strong>Amazon Simple Notification Service or SNS.</strong>  
 
 
 ![image](https://user-images.githubusercontent.com/88903134/183239022-cd1f53a0-be94-426f-ba42-a008c78231b2.png)


## Monolithic Application And Microservices

Applications are made of multiple components. The components communicate with each other to transmit data, fulfill requests, and keep the application running.

Now we have two approaches to combine the elements. The <strong> Monolithic Architecture </strong> where the components including databases, servers, the user interface, business logic, all are tightly coupled. In this approach to application architecture, if a single component fails, other components fail, and possibly the entire application fails.

![image](https://user-images.githubusercontent.com/88903134/183239311-c2706474-5e89-4880-89d6-af8904fbfff6.png)

The second approach <strong>aims to help maintain application availability when a single component fails</strong>, that is you can design your application through a microservices. In a microservices approach, application components are loosely coupled. The loose coupling prevents the entire application from failing. 


![image](https://user-images.githubusercontent.com/88903134/183239412-8b2bb1ce-9abc-44ac-b31d-9176af662d4e.png)


When designing applications on AWS, it is advisable to take a microservices approach with services and components that fulfill different functions. Two services facilitate application integration i.e. Applicatoin A and Application B in the previous example are: Amazon Simple Notification Service <strong>(Amazon SNS)</strong> and Amazon Simple Queue Service <strong>(Amazon SQS)</strong> approach.


## Amazon Simple Notification Service (Amazon SNS)

Amazon Simple Notification Service (Amazon SNS) is a publish/subscribe service. Using Amazon SNS topics, a publisher publishes messages to subscribers.

In Amazon SNS, <strong>subscribers can be web servers, email addresses, AWS Lambda functions,</strong> or several other options. 

## Amazon Simple Queue Service (Amazon SQS)

Amazon Simple Queue Service (Amazon SQS) is a message queuing service.  
Using Amazon SQS, you can send, store, and receive messages between software components, without losing messages or requiring other services to be available. In Amazon SQS, an application sends messages into a queue. A user or service retrieves a message from the queue, processes it, and then deletes it from the queue.




### Serverless Computing

I would like to revisit the topic of serverless computing, which is a service that lets you run virtual servers in the cloud. The term <strong>“serverless”</strong> means that your code runs on servers, but you do not need to provision or manage these servers. With serverless computing, you can focus more on innovating new products and features instead of maintaining servers. Another benefit of serverless computing is the <strong>flexibility to scale</strong> serverless applications automatically. Serverless computing can <strong>adjust the applications' capacity by modifying the units of consumptions, such as throughput and memory.</strong> 

> An AWS service for serverless computing is <strong>AWS Lambda.</strong>

### AWS Lambda

AWS Lambda is a serverless compute service that runs the code in response to events and <strong>automatically manages the underlying compute resources for the client</strong>. These events may include changes in state or an update, multiple events, such as HTTP requests via Amazon API Gateway, modifications to objects in Amazon Simple Storage Service (Amazon S3) buckets, table updates in Amazon DynamoDB, and state transitions in AWS Step Functions. AWS Lambda can be used to extend other AWS services with custom logic, or create your own backend services that operate at AWS scale, performance, and security.

Lambda has its key highlights including server and operating system maintenance, capacity provisioning and automatic scaling, code and security patch deployment, and code monitoring and logging.

## How Lambda Works

![image](https://user-images.githubusercontent.com/88903134/183347003-fcbcb234-ee25-4573-8910-28e1aca5e1cc.png)


Another additional service is <strong>Containerization</strong> of applications.

### Containers

Containers provide you with a standard way to package your application's code and dependencies into a single object. It is the orchestration service that helps you to deploy, manage, and scale your containerized applications. They smoothen the workflow with security, reliability and scalability.


Amazon provides two containerized services :
- <strong>Amazon Elastic Container Service (Amazon ECS) : </strong>
   This is a highly scalable, high-performance container management system that enables you to run and scale containerized applications on AWS. <strong>Amazon ECS supports Docker containers.</strong>
- <strong>Amazon Elastic Kubernetes Service (Amazon ECS) : </strong>
   This is a fully managed service that you can use to run Kubernetes on AWS. 
   
 There is also another service <strong>AWS Fargate</strong>.

 ![image](https://user-images.githubusercontent.com/88903134/183348897-b5b7a089-6633-4012-be2b-df9de6dc88d5.png)


AWS Fargate is a serverless compute engine for containers. It works with both Amazon ECS and Amazon EKS. 
When using AWS Fargate, you do not need to provision or manage servers. <strong>AWS Fargate manages your server infrastructure for you.</strong> You can focus more on innovating and developing your applications, and you pay only for the resources that are required to run your containers.