Elastic Container Service (ECS) vs Lambda Flashcards
Amazon EC2 Container Service
Amazon ECS is a highly scalable, high performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon EC2 instances. ECS elminates the need for you to install, operate, and sclae your own cluster management infrastructure
With ECS, deploying containerized applications is easily accomplished. This service fits well in running batch jobs or in a microservice architecture
You have a central repo where you can upload your Docker images from ECS container for safekeeping called Amazon ECR
Applications in ECS can be written in a stateful or stateless matter
The Amazon ECS CLI supports Docker Compose, which allows you to simplify your local development experience as well as easily set up and run your containers on Amazon ECS
Since your applications still run on EC2 instances, server management is your responsibility. This gives you more granular control over your system
It is up to you to manage scaling and load balacing of your EC2 instances as well, unlike in AWS Lambda where functions scale automatically
You are charged for the costs incurred by your EC2 instances in your clusters. Most of the time, Amazon ECS most more than using AWS Lambda since your active EC2 instances will be charged hourly
One version of Amazon ECS, known as AWS Fargate, will fully manage your infrastructure so you can just focus on deploying containers. AWS Fargate has a different pricing model from the standard EC2 cluster
ECS will automatically recover unhealthy containers to ensure that you have the desired number of containers supporting your application
BREAK
AWS Lambda
AWS Lambda is a function as a service offering that runs your code in response to events and automatically manages the compute resources for you, since Lambda is a serverless compute service. With Lambda, you do not have to worry about managing servers, and directly focus on your application code
Lambda automatically scales your function to meet demands. It is noteworthy however that Lambda has a maximum execution duration per request of 900 seconds or 15 minutes
To allow your Lambda function to access other services such as CloudWatch Logs, you would need to create an execution role that has the necessary permissions to do so.
You can easily integrate your function with different services such as API Gateway, DynamoDB, CloudFront etc using the Lambda Console
You can test your functiion code locally in the Lambda console before launching it into production
Currently Lambda supports only a number of programming languages such as Java, Go, PowerShell, Node.js, C#, Python and Ruby. ECS is not limited by programming languages since it mainly caters to Docker
Lambda functions must be stateless since you do not have volumes for data storage
You are charged based on the number of requests for your functions and the duration, the time it takes for your code to execute. To minimize costs, you can throttle the number of concurrent executions running at a time, and the execution time limit of the function
With Lambda@Edge, AWS Lambda can run your code across AWS Locations globally in response to Amazon CloudFront events, such as requests for content to or from origin servers and viewers. This makes it easier to deliver content to end users with low latency