Amazon ECS, Lambda, Fargate
Tags: aws, docker, lambda
Published: 2022-05-03 00:20:44

_ECS (Elastic Container Service)_
In this service, you need to create EC2 instances in advance. AWS takes care of other things. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye744t7skyl2wouvkknz.png)

_Fargate_ 
There is fargate which is a serverless offering and we don't need to create EC2 instances in advance in this case.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kynocd9m30m6shjtq5vv.png)
_ECR_
In AWS we are going to keep our images on ECR (Elastic Container Registry).  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nm3490lndr5i3yqwial8.png)

_AWS Lambda_
It consists of functions and it has short executions and runs on demand.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95l22vucj09u0ho05eh2.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07zr645b3awcipsg8uok.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vplaewt48cihjvqm5wid.png)
One common use case is Serverless Thumbnail creation
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aj3t75kdar7cunipn1v3.png)
Assume one wants to upload a beach picture to an Amazon S3 bucket,a lambda will be triggered and it will create a thumbnail of the picture and send it to the S3. Also, it will create some metadata of the picture and send it to DynamoDB. 

another famous common use is Serverless CRON Job.
CRON allows you to define the schedule. Based on the schedule the scripts are run. 
CloudWatch Events EventBridge is a serverless offering that triggers Lambda every 1 hour. 


Pricing: https://aws.amazon.com/lambda/pricing/
The cost is based on calls and duration.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/etop51948upsh467rnj6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yhjflmmsm3mz7jsaqwy.png)
 
 
_Amazon API Gateway_

Assume that you have lambda and DynamoDB connected together and you want a client to get access to Lambda which is not possible because Lambda is not exposed. Now you will have an API Gateway between Client and Lambda so that both of them can connect. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmd462v6b544966rcgif.png)


_AWS Batch _
AWS Batch enables developers, scientists, and engineers to easily and efficiently run hundreds of thousands of batch computing jobs on AWS. AWS Batch dynamically provisions the optional quantity and type of compute resources based on the volumes and specific resource requirements of the batch jobs submitted. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox78ub4von4s4rnyfsqi.png)
For example, you upload a picture to Amazon S3 and it will trigger AWS Batch and Batch will call ECS which will already have EC2 and other instances to run your object and then return as required. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mi25xt2jhk2ge57sl4bz.png)

Lambda vs Batch
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0m7qm2zr7l0spbce3v3b.png)

_Amazon Lightsail_
It is basically a package of virtual servers, storage, database, and networking. Generally people uses it if there is no cloud experience of the user. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gqjiauzhgnkqn61g7pk2.png)

Summary
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nej4ufej12w42tlwm6jr.png)