All guides
Practice now
D3 · Cloud technology and services

Compute: EC2, Lambda, and containers

D3 is the domain with the highest weight (34%). AWS offers multiple compute options. The CLF-C02 exam tests scenarios where you must choose the right service: EC2 vs Lambda, On-Demand vs Reserved vs Spot, ECS vs vs Fargate.

Compute options on AWS

EC2

IaaS

VMs with full control

Lambda

Serverless

Code with no servers

ECS/EKS

Containers

Container orchestration

Beanstalk

PaaS

Managed app deployment

Amazon — IaaS in detail

Icon-Architecture/48/Arch_Amazon-EC2_48

Elastic Compute Cloud — virtual servers in the AWS cloud

Amazon EC2 provides secure, resizable compute capacity in the cloud. It lets you provision instances (virtual servers) with the operating system, CPU type, RAM, and storage you need.

Key EC2 concepts

Instance Types

Combinations of CPU, memory, storage, and network. E.g.: t3.micro (general purpose), c5.xlarge (compute-optimized), r5.large (memory-optimized).

AMI (Amazon Machine Image)

A template containing the OS and software. It's the "image" an instance is launched from. Can come from AWS, the AWS Marketplace, or be custom.

Security Groups

A virtual firewall at the instance level. They are stateful: if you allow inbound traffic, the outbound response is automatically allowed. Only Allow rules exist (no Deny).

Key Pairs

A public/private key pair for SSH access (Linux) or to decrypt the Windows password. AWS keeps the public key, you keep the private one.

User Data

A script that runs the first time the instance launches. Useful for installing software, applying settings, etc.

Instance Store vs EBS

Instance Store = ephemeral storage (lost when the instance stops). EBS = persistent storage (survives stops and reboots).

Instance type families

FamilyOptimized forExamples
t, mGeneral purposet3.micro, m5.large
cCompute (CPU)c5.xlarge, c6g.medium
r, x, zMemory (RAM)r5.large, x1e.32xlarge
i, d, hStoragei3.xlarge, d3.xlarge
p, g, infGPU / MLp3.2xlarge, g4dn.xlarge
a1, c6gARM (Graviton)c6g.medium (more cost-effective)

EC2 pricing models

On-Demand

Baseline price (reference)

Pay for the compute time of the instances you use (per hour or per second). No long-term commitment or upfront payment.

When to use

Apps with unpredictable workloads. Development and testing. Users who do NOT want a long-term commitment.

Reserved Instances (RI)

Up to 72% vs On-Demand

A commitment to use a specific instance configuration for 1 or 3 years. Paid all upfront, partial upfront, or monthly.

When to use

Apps with steady state and predictable usage. Production workloads running 24/7. When you know exactly which instance type you'll need for at least a year.

Savings Plans

Up to 66% vs On-Demand

A commitment to spend ($/hour) for 1 or 3 years. More flexible than Reserved — applies to any instance type, region, or family (Compute Savings Plans).

When to use

When you want Reserved-level savings but with more flexibility. Stable workloads that may still change instance type or region.

Spot Instances

Up to 90% vs On-Demand

Use AWS's spare capacity at the market spot price. AWS can interrupt the instance with a 2-minute warning when it needs that capacity back.

When to use

Interruption-tolerant workloads: image processing, rendering, big data analysis, HPC. NOT for critical production.

Dedicated Hosts

Variable — no capacity discount

A physical server fully dedicated to your use. You see the physical socket, cores, and host identifiers.

When to use

Software licenses that require physical sockets/cores (BYOL). Compliance requirements that prohibit shared hardware. More expensive than the other options.

EC2 instance families — Naming

AWS organizes EC2 instances into families based on their optimization target. The instance name encodes family, generation, and size: t3.micro = family T, generation 3, size micro.

FamilySeriesOptimizationUse cases
General purposeM, T (t2/t3/t4g)Balanced CPU/memoryWeb servers, small applications, dev databases
Compute optimizedC (c5/c6/c7g)High-performance processorsBatch processing, gaming, HPC, video encoding
Memory optimizedR, X, z (r5/x1e/z1d)Large amounts of RAMIn-memory databases, real-time Big Data, SAP HANA
Storage optimizedI, D, H (i3/d3/h1)High sequential and random I/OData warehousing, distributed file systems, Hadoop
Accelerated computingP, G, Inf (p3/g4dn/inf1)GPUs / hardware acceleratorsML training and inference, 3D rendering, gaming

Instance naming

tFamily (burstable general purpose)3Generation (3rd gen — newer = better performance/price).microSize: nano < micro < small < medium < large < xlarge < 2xlarge...

Auto Scaling and Elastic Load Balancing

Icon-Architecture/48/Arch_Amazon-EC2-Auto-Scaling_48

AWS

Automatically adjusts the number of EC2 instances based on demand. Define a scaling group with a minimum, desired, and maximum capacity.

Minimum

Always running (e.g.: 2)

Desired

Normal state (e.g.: 4)

Maximum

Scaling limit (e.g.: 10)

  • • Scale-out: adds instances when CPU > 70%
  • • Scale-in: removes instances when CPU < 30%
  • • Based on CloudWatch metrics or a schedule

Elastic Load Balancing ()

Distributes incoming traffic across multiple EC2 instances, containers, or IPs in one or more AZs.

ALB — Application LB

Layer 7 HTTP/S. Routing by URL, headers, HTTP methods. For web apps and microservices.

NLB — Network LB

Layer 4 TCP/UDP/TLS. Ultra-low latency, millions of req/sec. For high-performance applications.

GWLB — Gateway LB

For third-party security appliances (firewalls, IDS). Layer 3.

CLB — Classic LB

Legacy. Do not use for new applications. Use ALB or NLB instead.

Auto Scaling + ELB = Elastic, highly available architecture

ELB spreads traffic across healthy instances. Auto Scaling adds or removes instances based on load. Together they let the application handle any traffic level without manual intervention, with multi-AZ high availability.

Other compute services

Icon-Architecture/48/Arch_AWS-Batch_48

AWS Batch

Runs batch computing jobs at any scale without managing the underlying infrastructure. Define the job in a container, and AWS provisions the necessary resources automatically.

  • • Manages the job queue automatically
  • • Provisions EC2 or Fargate based on load
  • • Difference from Lambda: no execution time limit
  • • Ideal for: simulations, rendering, genomics analysis

AWS Outposts

Physical AWS hardware installed in the customer's datacenter. Provides the same AWS APIs, tools, and services, but locally.

  • • Same experience as AWS, but on-premises
  • • For ultra-low latency or local data residency
  • • AWS manages the hardware remotely
  • • Hybrid deployment model

AWS — Serverless

Icon-Architecture/48/Arch_AWS-Lambda_48

Run code without provisioning or managing servers

AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time consumed — nothing is charged when the code isn't running.

Lambda characteristics

  • •
    Languages: Node.js, Python, Java, Go, Ruby, .NET, custom runtime
  • •
    Timeout: maximum 15 minutes per execution
  • •
    Memory: 128 MB to 10 GB, configurable
  • •
    Concurrency: scales to thousands of parallel executions automatically
  • •
    Cold start: the first invocation can have extra latency (milliseconds to seconds)

Common Lambda triggers

  • • S3: event when an object is uploaded/deleted
  • • API Gateway: HTTP/REST/WebSocket request
  • • DynamoDB Streams: changes to a table
  • • SNS: message on a topic
  • • SQS: message on a queue
  • • CloudWatch Events/EventBridge: scheduled events (cron)
  • • Cognito: authentication triggers
  • • Kinesis: real-time data stream

Lambda pricing

Per request

$0.20 per million requests. The first 1 million are free (always, not just under the free tier).

Per duration

Billed in 1ms increments. Based on configured memory × execution time.

Containers: ECS, EKS, and Fargate

Icon-Architecture/48/Arch_Amazon-Elastic-Container-Service_48

Amazon

Elastic Container Service

Docker container orchestration managed by AWS. Simpler than Kubernetes. Native integration with AWS services.

  • • AWS's own orchestration engine (not K8s)
  • • Easier to set up than EKS
  • • Can be used with Fargate (serverless) or EC2
Icon-Architecture/48/Arch_Amazon-Elastic-Kubernetes-Service_48

Amazon EKS

Elastic Kubernetes Service

Managed Kubernetes on AWS. If you already use Kubernetes on another cloud or on-premises, EKS eases migration and keeps things consistent.

  • • Standard Kubernetes (portability)
  • • More complex than ECS
  • • Compatible with the K8s ecosystem
Icon-Architecture/48/Arch_AWS-Fargate_48

AWS

Serverless containers

A serverless engine for containers. Removes the need to manage EC2 instances for ECS or EKS. You pay only for the CPU and memory resources used.

  • • No server management
  • • Compatible with both ECS and EKS
  • • Pay per use (CPU + memory)

Quick rule for the exam

ECS = containers on AWS, AWS-native orchestration, no prior K8s experience

EKS = you already use Kubernetes, need multi-cloud portability

Fargate = containers WITHOUT managing EC2 servers (serverless containers)

Lambda = code WITHOUT containers, event-driven, short-lived functions

Elastic Beanstalk and Amazon Lightsail

Icon-Architecture/48/Arch_AWS-Elastic-Beanstalk_48

AWS Elastic Beanstalk

PaaS — Deploy without managing infrastructure

Deploys and scales web applications automatically. Just upload your code and Beanstalk handles provisioning, load balancing, scaling, and monitoring.

  • • Supports: Node.js, Python, Java, PHP, Ruby, Go, .NET
  • • Full access to the underlying EC2 resources
  • • No extra cost — you pay for the resources (EC2, RDS)
  • • Ideal for: developers who don't want to manage infrastructure
Icon-Architecture/48/Arch_Amazon-Lightsail_48

Amazon Lightsail

Simple VPS — predictable fixed pricing

Simple virtual servers with a fixed monthly price. Designed for less technical users or small projects that need a simple VPS without the complexity of full AWS.

  • • Starting at $3.50/month with 512MB RAM, 1vCPU, 20GB SSD
  • • Fixed, predictable pricing (not variable pay-per-use)
  • • Includes static IP, DNS, monitoring, backups
  • • Ideal for: simple websites, blogs, small dev/test
Related labD3 · Cloud Technology and Services

Deploy an app with AWS Elastic Beanstalk

Deploy a sample application without manually managing EC2, Load Balancer, or Auto Scaling.

Understand Elastic Beanstalk's PaaS model versus managing EC2 manually
Create an environment with a managed platform

+1 more...

8 min6 steps

Comparison table — Which service should you use?

ServiceOS controlInfra managementScalingBest for
EC2FullCustomerManual or Auto ScalingLift-and-shift, full control, custom OS
LambdaNoneAWS 100%Automatic down to zeroEvent-driven, short functions, zero infra
ECS (EC2)EC2 yesContainers: AWS; EC2: customerECS AutoscalingContainers with server control
ECS/EKS (Fargate)NoneAWS 100%AutomaticServerless containers, no EC2 management
EKSControl plane: AWSNative KubernetesKubernetes HPAK8s portability, teams with K8s expertise
Elastic BeanstalkEC2 access availableAWS manages the deploymentAutomaticDevs who just want to push code
LightsailYes (VPS)Simple AWS UIManualSimple VPS, fixed price, small projects
Related labD3 · Cloud Technology and Services

Launch an EC2 instance

Learn to launch your first compute instance on AWS and understand the IaaS model.

Understand what Amazon EC2 is and the IaaS model
Select an AMI (Amazon Machine Image)

+2 more...

12 min6 steps
Related labD3 · Cloud Technology and Services

Create a Lambda function

Deploy your first serverless function with AWS Lambda and configure a trigger.

Understand serverless vs IaaS
Create a Lambda function

+1 more...

12 min8 steps
Related labD3 · Cloud Technology and Services

Configure Auto Scaling

Set up an Auto Scaling group to scale EC2 automatically based on demand.

Understand elasticity as a pillar of the cloud
Create an Auto Scaling Group

+1 more...

15 min8 steps
Related labD3 · Cloud Technology and Services

Challenge: choose the right compute

No guided steps: read a scenario with several stacked requirements and pick, out of 4 compute services, the only one that meets all of them.

Compare EC2, Lambda, Elastic Beanstalk, and ECS Fargate
Recognize when an "OS control" requirement rules out the serverless/PaaS options

+1 more...

4 min1 steps

Did you get this topic?

Test what you just learned

A company runs a production web application that operates 24/7, 365 days a year, with no planned interruptions. The team wants to reduce EC2 compute costs as much as possible. The app has a stable, predictable load profile. Which EC2 pricing model is recommended?

Ready to test "Compute: EC2, Lambda, and containers"?

Put what you learned to the test with original CLF-C02 exam questions.

Start CLF-C02 mock exam

Unlimited mock exams with the Pro plan

Log in to track your progress.