Lesson 0003: Serverless and Containers

AWS Lambda, Amazon ECS, Amazon EKS, AWS Fargate, and AWS Elastic Beanstalk

1. The Compute Spectrum

AWS offers four categories of compute. Each trades control for convenience. The exam tests whether you can match the use case to the right category.

CategoryServicesYou ManageAWS Manages
Virtual Machines (IaaS)Amazon EC2OS, patching, scaling, availabilityHypervisor, host hardware, network
ContainersECS, EKS, Fargate, ECRContainer images, task definitionsOrchestration, cluster scaling, control plane
ServerlessAWS LambdaFunction code and IAM permissionsServers, scaling, patching, availability
Platform (PaaS)AWS Elastic BeanstalkApplication codeInfrastructure, deployment, load balancing, scaling

2. Containers on AWS

What is a Container?

Containers are a method of operating system virtualization. They package an application's code, configurations, and dependencies into a single object. Unlike virtual machines, containers do not contain a full guest operating system. They share the host OS kernel and run as resource-isolated processes.

Containers vs. Virtual Machines: VMs run on a hypervisor with a full guest OS per instance. Containers run on a shared OS kernel via a container engine (such as Docker). Containers are smaller and faster to start.

Docker is the software platform that packages software into containers. You create a container from an image, which is a template that holds everything the software needs to run: libraries, system tools, code, and runtime.

Amazon Elastic Container Service (Amazon ECS)

Amazon ECS is a highly scalable container management service that supports Docker containers. It orchestrates the running of containers on a cluster and maintains the fleet of nodes that run them.

To run an application on ECS, you create a task definition. This text file describes one or more containers (up to ten) that form your application. It specifies which container image to use, which ports to open, and what data volumes to mount. A task is the instantiation of a task definition within a cluster.

ECS Launch Types:

Amazon Elastic Kubernetes Service (Amazon EKS)

Amazon EKS is a managed Kubernetes service. Kubernetes is open source software for container orchestration that deploys and manages containerized applications at scale.

EKS makes it easy to run Kubernetes on AWS without installing or maintaining your own Kubernetes control plane. It is certified Kubernetes conformant, so applications that run on upstream Kubernetes are compatible with EKS. EKS automatically manages the availability and scalability of cluster nodes, detects unhealthy control plane nodes, and replaces them.

ECS vs. EKS: Both orchestrate Docker containers. Use ECS if you want AWS-native orchestration. Use EKS if you need Kubernetes compatibility, open source tooling, or a multi-cloud strategy.

Amazon Elastic Container Registry (Amazon ECR)

Amazon ECR is a fully managed Docker container registry. It makes it easy to store, manage, and deploy Docker container images. ECR is integrated with both ECS and EKS. Images are encrypted at rest.

3. Serverless with AWS Lambda

AWS Lambda is an event-driven, serverless compute service. You upload your code as a Lambda function and set it to run on a schedule or in response to an event. Your code runs only when triggered. You pay only for the compute time you consume.

Lambda Benefits:

Lambda Event Sources

Lambda functions are triggered by event sources. Common event sources include:

Lambda automatically monitors functions through Amazon CloudWatch and stores logs in CloudWatch Logs.

Lambda Limits

LimitValue
Maximum execution time (timeout)15 minutes
Maximum memory allocation10,240 MB
Concurrent executions per Region (soft limit)1,000
Deployment package size (unzipped)250 MB

4. Platform as a Service: AWS Elastic Beanstalk

AWS Elastic Beanstalk is a platform as a service (PaaS) that facilitates the quick deployment, scaling, and management of web applications. You upload your code, and Elastic Beanstalk automatically handles deployment, capacity provisioning, load balancing, automatic scaling, and health monitoring.

Elastic Beanstalk Key Facts:

5. Decision Guide

Use CaseServiceWhy
Run code in response to events, pay per executionAWS LambdaNo servers to manage; millisecond billing
Run Docker containers with AWS managing the clusterAmazon ECS with FargateNo EC2 instances to provision or scale
Run Docker containers with full control over the hostsAmazon ECS with EC2Granular control over instance type and networking
Use Kubernetes on AWS without managing the control planeAmazon EKSManaged Kubernetes, certified conformant
Deploy a web app quickly without managing infrastructureAWS Elastic BeanstalkPaaS with auto-deployment, scaling, and monitoring
Store and manage Docker imagesAmazon ECRFully managed registry integrated with ECS and EKS

Quiz: Serverless and Containers

Select one answer per question. You will receive immediate feedback.

1. A company wants to run Docker containers but does not want to manage the EC2 instances that run them. Which service and launch type should they use?
2. A developer needs to run a small Python script whenever a file is uploaded to S3. The script runs for less than 5 seconds. Which is the most cost-effective service?
3. Which AWS service is a fully managed Docker container registry that integrates with ECS and EKS?
4. A company uses Kubernetes on-premises and wants to migrate to AWS without changing their operational tooling. Which service should they use?
5. What is the maximum execution time (timeout) for a single AWS Lambda function invocation?
6. A startup wants to quickly deploy a web application without managing servers, load balancers, or scaling. They want to upload their code and have AWS handle the rest. Which service fits best?
7. Which statement accurately describes the difference between containers and virtual machines?
8. A company needs to orchestrate Docker containers and wants AWS to manage the control plane automatically. They also want Kubernetes compatibility. Which service should they choose?
Progress: 0/8 correct (0%). Answer all questions to see the final recommendation.
Ask your teacher: Ask your agent about anything unclear: Lambda event sources, ECS task definitions, or when to choose Fargate over EC2.
Primary Source: AWS Academy Module 6: Compute.