π§ Core Idea
EC2 instances stay powered on whether they're busy or not. Lambda flips that: upload your code as a function, and AWS runs it only when needed, scales it automatically, and charges you only while it executes.
β‘ What is AWS Lambda?
A serverless compute service β run code with no servers to provision or manage. Upload a function; AWS handles the rest:
Executes your code
Allocates compute resources
Scales automatically
Stops when the function finishes
You're billed only while it's running.
Lambda is built for short-running, event-triggered tasks:
An event occurs (upload, request, schedule, etc.)
AWS starts the function
It processes and finishes
AWS releases the resources
No event = no running function = no charge.
No Auto Scaling Groups needed β Lambda scales with request volume on its own.
One request β one execution. Thousands of simultaneous requests β Lambda spins up that many executions automatically.
Lambda runs only when triggered β by things like:
A file uploaded to S3
A database update
An API request
A schedule
A message in a queue
Compute is only used when there's actual work to do.
Pay-as-you-go, based on:
Number of requests
Compute duration
Free tier: 1M requests/month + 400,000 GB-seconds/month of compute.
Exam tip: Lambda pricing = requests + execution duration.
Up to 10 GB memory per function β more memory also means more CPU/network performance
Supports Node.js, Python, Java, C#, .NET Core, PowerShell, Ruby β plus Rust/Go via Custom Runtime API
For the exam, just know Node.js and Python are most common
π¦ Container Images
Lambda can run container images too β but ECS and Fargate remain the preferred services for Docker workloads on the exam. Lambda is built for functions, not general containers.
π₯οΈ EC2 vs. Lambda
πΉ | π₯οΈ EC2 | β‘ Lambda |
|---|---|---|
Model | Server, runs continuously | Function, runs only when invoked |
Sizing | You choose CPU/memory/storage | AWS manages it |
Management | You manage OS/servers | None required |
Scaling | Manual or Auto Scaling Group | Automatic |
Billing | While instance runs | While function executes |
Core difference: EC2 is server-based, Lambda is function-based.
πΌοΈ Use Case: Serverless Thumbnail Generation

User uploads an image to S3
S3 triggers a Lambda function
Lambda generates a thumbnail
Thumbnail saved back to S3
Metadata stored in DynamoDB
Fully serverless β S3, Lambda, and DynamoDB all scale automatically with zero server management.
β° Use Case: Scheduled Tasks (CRON)

No EC2 instance needed for scheduled jobs anymore:
Amazon EventBridge sets a schedule
It triggers a Lambda function
Lambda performs the task
Examples: hourly cleanup scripts, daily reports, scheduled backups. Both EventBridge and Lambda are serverless β nothing to manage.
π Why Lambda is Popular
No server management
Automatic scaling
Pay only for usage
Faster development
Deep integration with AWS services
π Exam Tips
Lambda = serverless compute, runs functions, not servers
Triggered only by events
Scales automatically
Integrates with S3, EventBridge, and more
Supports Node.js, Python, and others
For containers, ECS/Fargate are preferred over Lambda
Pricing = requests + execution duration
"Run code without managing servers" β Lambda
π§ Key Takeaways
Lambda is a fully managed, serverless compute service
Runs only when triggered by an event
Scales automatically; billed only for requests + execution time
Common use cases: image processing, scheduled tasks, backend APIs
For containers, ECS/Fargate are the preferred choice
Lambda = Serverless Compute + Event-Driven + Pay Per Request/Duration