/Compute Services (EC2, Lambda, Containers)
Concept
Medium

Compute Services (EC2, Lambda, Containers)

7 min read·ec2lambdafargateecsekselastic-beanstalkauto-scalingload-balancingpurchasing-optionsserverlessclf-c02

AWS compute spans virtual machines (EC2), serverless functions (Lambda), and containers (ECS, EKS, Fargate). EC2 purchasing options — On-Demand, Reserved, Spot, Savings Plans, and Dedicated Hosts — offer significant cost optimization. Choosing the right compute depends on control needs, workload patterns, and how much operational overhead you want to manage.


1. AWS Compute — The Spectrum

Rendering diagram…

2. Amazon EC2 — Virtual Servers

EC2 provides virtual servers (instances) with full control over the operating system, installed software, networking, and storage. You are responsible for the guest OS and everything running on it.

EC2 Instance Families

FamilyOptimized ForTypesCommon Use Cases
General Purpose (M, T)Balanced compute/memory/networkt3.micro, m6i.largeWeb servers, dev/test, small databases
Compute Optimized (C)High vCPU-to-memory ratioc6i.large, c7g.xlargeBatch processing, gaming servers, ML inference
Memory Optimized (R, X)Large in-memory datasetsr6i.large, x2gd.xlargeIn-memory databases, SAP HANA, big data analytics
Storage Optimized (I, D)High sequential I/O, local NVMei3.large, d3.xlargeOLTP databases, data warehousing, Hadoop
Accelerated Computing (P, G)GPU / hardware acceleratorsp3.xlarge, g5.xlargeML training, video rendering, scientific computing

EC2 Purchasing Options

Rendering diagram…
OptionMax SavingsCommitmentInterruptionBest For
On-Demand0%NoneNeverVariable, unpredictable workloads; dev/test
Reserved (Standard)Up to 72%1 or 3 yrNeverSteady-state known workloads
Reserved (Convertible)Up to 54%1 or 3 yrNeverWhen you might change instance family
Compute Savings PlansUp to 66%1 or 3 yr ($/hr)NeverFlexible — any family, size, region, OS
Spot InstancesUp to 90%NoneYES — 2-min warningBatch jobs, data analysis, fault-tolerant apps
Dedicated HostsVariesOptional 1/3 yrNeverBYOL licenses, regulatory compliance
Dedicated InstancesVariesOn-Demand or RINeverPhysical isolation from other customers

3. AWS Lambda — Serverless Functions

Lambda lets you run code without provisioning or managing servers. You upload your code; Lambda handles compute, scaling, and availability automatically.

Rendering diagram…

Lambda key facts:

FeatureDetail
LanguagesNode.js, Python, Java, Go, .NET, Ruby, custom runtimes
Max execution time15 minutes per invocation
Memory128 MB to 10 GB (CPU scales proportionally)
PricingPer request + duration in GB-seconds; generous free tier
ScalingAutomatic — thousands of concurrent executions
StateStateless — no persistent local state between invocations

4. Container Services

Containers package code with its dependencies into a portable unit that runs consistently anywhere.

Rendering diagram…
ServiceDescription
Amazon ECSAWS-native Docker container orchestration; simpler to operate
Amazon EKSAWS-managed Kubernetes; use when you need Kubernetes compatibility
Amazon ECRPrivate container image registry; integrated with ECS and EKS
AWS FargateServerless compute for containers — no EC2 nodes to manage; works with ECS and EKS

ECS vs EKS:

  • ECS — AWS-proprietary, simpler, less operational overhead, tightly integrated with IAM/ALB/CloudWatch
  • EKS — Kubernetes-compatible, portable across clouds, more complex, larger ecosystem

5. Elastic Beanstalk — Managed App Platform

  • Deploy web applications without managing the underlying infrastructure
  • Supports: Node.js, Python, Java, PHP, Ruby, Go, .NET, Docker
  • AWS manages: EC2 provisioning, load balancer setup, auto scaling, OS patching, health monitoring
  • You manage: Application code and application-level configuration
  • Free service — pay only for the underlying AWS resources it provisions (EC2, ELB, RDS)
  • Good choice when you want the simplicity of PaaS but still need some control

6. Amazon Lightsail — Simple Virtual Servers

  • Predictable, all-inclusive monthly pricing (compute + storage + data transfer bundled)
  • Managed VPS service aimed at simpler workloads
  • Best for: WordPress sites, simple web apps, developer sandboxes, small business websites
  • Includes: Virtual server, SSD storage, DNS management, static IPs, snapshots

7. AWS Batch — Managed Batch Processing

  • Fully managed service for large-scale batch computing workloads
  • Automatically provisions the right type and quantity of EC2 instances
  • Use cases: Financial risk modeling, genomics analysis, image/video rendering, ETL pipelines
  • You define jobs; AWS Batch handles scheduling and compute provisioning

8. EC2 Auto Scaling & Elastic Load Balancing

Rendering diagram…

EC2 Auto Scaling:

  • Automatically launches instances when demand rises; terminates them when demand falls
  • Maintains a specified minimum number of healthy instances at all times
  • Driven by CloudWatch alarms (CPU utilization, custom metrics, schedules)

Elastic Load Balancing (ELB) types:

TypeLayerProtocolUse Case
ALB (Application LB)Layer 7HTTP / HTTPSWeb apps, microservices, path and host-based routing
NLB (Network LB)Layer 4TCP / UDPUltra-low latency, static IPs, gaming, IoT, VoIP
GLB (Gateway LB)Layer 3IP packetsDeploy third-party firewalls and IDS/IPS appliances

9. CLF-C02 Quick Reference

TopicKey Fact
EC2Virtual servers; full OS control; you patch the guest OS
On-DemandNo commitment; full price; most flexible
Reserved Instances1 or 3 yr; up to 72% savings; steady-state workloads
Spot InstancesUp to 90% savings; can be interrupted with 2-min warning
Savings PlansFlexible $/hr commitment; up to 66% savings
Dedicated HostsPhysical server; bring your own license; compliance
LambdaServerless; event-triggered; max 15 min; auto-scales
FargateServerless containers; no EC2 nodes; works with ECS and EKS
ECSAWS-native container orchestration
EKSAWS-managed Kubernetes
ECRContainer image registry
Elastic BeanstalkDeploy web apps; AWS manages infrastructure; you manage code
LightsailSimple predictable-cost VPS for small workloads
Auto ScalingAdjusts EC2 instance count based on demand; maintains healthy instances
ALBLayer 7; HTTP/HTTPS; path-based routing
NLBLayer 4; TCP/UDP; ultra-low latency; static IPs

Practice Questions10

easy

Q1. Which EC2 purchasing option provides the highest discount (up to 90%) but can be interrupted by AWS with a 2-minute notification when capacity is needed?


Select one answer before revealing.

easy

Q2. A company runs a production database that must be online 24/7 for the next 3 years. Which EC2 purchasing option provides the MOST cost savings?


Select one answer before revealing.

easy

Q3. Which AWS service lets you run code in response to events without provisioning or managing any servers, charging only for the compute time consumed?


Select one answer before revealing.

medium

Q4. What is the maximum execution duration for a single AWS Lambda function invocation?


Select one answer before revealing.

medium

Q5. A company wants to run Docker containers on AWS without managing or provisioning any EC2 instances. Which TWO services allow running containers where AWS fully manages the underlying infrastructure? (Select TWO — more than one answer may be correct)


Select one answer before revealing.

easy

Q6. Which AWS service automatically increases and decreases the number of EC2 instances in response to changing demand metrics like CPU utilization?


Select one answer before revealing.

medium

Q7. Which EC2 purchasing option gives you a physical server dedicated exclusively to your use, which is required to use your existing per-socket or per-core server software licenses?


Select one answer before revealing.

easy

Q8. A developer wants to deploy a web application to AWS quickly without worrying about infrastructure. They want AWS to handle capacity provisioning, load balancing, auto-scaling, and monitoring. Which service is best suited?


Select one answer before revealing.

hard

Q9. A company has a workload with a steady baseline but unpredictable spikes. They want to minimize costs while ensuring spikes are handled. Which combination BEST meets this need?


Select one answer before revealing.

medium

Q10. Which EC2 pricing model offers savings of up to 66% compared to On-Demand and provides flexibility to change instance family, size, OS, and Region during the commitment period?


Select one answer before revealing.