AWS Certified Cloud Practitioner / Other Compute Services: ECS, Lambda, Batch, Lightsail

Lambda Overview

🧠 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:

  1. An event occurs (upload, request, schedule, etc.)

  2. AWS starts the function

  3. It processes and finishes

  4. 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

  1. User uploads an image to S3

  2. S3 triggers a Lambda function

  3. Lambda generates a thumbnail

  4. Thumbnail saved back to S3

  5. 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:

  1. Amazon EventBridge sets a schedule

  2. It triggers a Lambda function

  3. 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