3.1 AWS Compute Services

Key Takeaways

  • Amazon EC2 provides resizable virtual servers (instances) in the cloud with full OS-level control — the core IaaS compute service.
  • AWS Lambda is a serverless compute service that runs code in response to events — you pay only for the compute time consumed.
  • Amazon ECS and Amazon EKS are container orchestration services for Docker and Kubernetes workloads respectively.
  • EC2 instance types are optimized for different use cases: General Purpose (T, M), Compute Optimized (C), Memory Optimized (R, X), Storage Optimized (I, D), and Accelerated Computing (P, G).
  • Auto Scaling automatically adjusts the number of EC2 instances based on demand to maintain performance and minimize cost.
Last updated: June 2026

Quick Answer: AWS compute spans a spectrum from full virtual servers (Amazon EC2) to fully serverless functions (AWS Lambda). For the CLF-C02 you must match a scenario to the right service: EC2 for full OS control, Lambda for short event-driven code, ECS/EKS for containers, Elastic Beanstalk for managed web apps, and AWS Fargate for serverless containers. You are tested on what and when, not how to configure.

Amazon EC2 (Elastic Compute Cloud)

Amazon EC2 provides resizable virtual servers, called instances, in the cloud. It is the foundational Infrastructure as a Service (IaaS) offering and the most widely used AWS compute service. You choose an Amazon Machine Image (AMI) (the template containing the operating system and software), pick an instance type (the hardware profile), and launch — typically in under a minute.

EC2 Key Features

  • Full control over the operating system (Linux, Windows, macOS) and installed software
  • Instance types optimized for different workloads (see families below)
  • Flexible pricing models (On-Demand, Reserved, Savings Plans, Spot, Dedicated)
  • Security Groups act as a stateful virtual firewall at the instance level
  • Elastic IP addresses provide a static public IPv4 address you can remap
  • EBS volumes for persistent storage and instance store for temporary storage
  • User data scripts run at first boot to automate configuration

EC2 Instance Families

FamilyOptimized ForExamplesUse Cases
General Purpose (T, M)Balanced compute, memory, networkingt3.micro, m6i.largeWeb servers, code repos, small/medium databases
Compute Optimized (C)High-performance processorsc6i.xlargeBatch processing, gaming servers, scientific modeling, HPC
Memory Optimized (R, X)Large in-memory datasetsr6i.large, x2idn.largeIn-memory databases (SAP HANA), real-time big-data analytics
Storage Optimized (I, D)High sequential read/write to local diski4i.large, d3.xlargeData warehousing, distributed file systems, NoSQL
Accelerated Computing (P, G)Hardware accelerators (GPUs)p5.48xlarge, g5.xlargeMachine learning training/inference, graphics rendering

On the Exam: You do NOT memorize specific sizes or prices. Memorize the mapping: T/M = general, C = compute, R/X = memory, I/D = storage, P/G = GPU/accelerated. A question describing "GPU-heavy machine learning training" points to P or G.

AWS Graviton

Many instance families offer a Graviton variant (e.g., m7g, c7g, r7g). Graviton is AWS's custom ARM-based processor that delivers better price-performance and lower energy use than comparable x86 instances. Graviton appears in Sustainability and Cost Optimization questions because it reduces both cost and carbon footprint.

EC2 Pricing Models

Pricing ModelDescriptionBest ForSavings vs. On-Demand
On-DemandPay per second (60-sec min, Linux) with no commitmentShort-term, spiky, first-time workloadsBaseline
Reserved Instances (RI)1- or 3-year commitment to a specific instance typeSteady-state, predictable workloadsUp to 72%
Savings PlansCommit to a $/hour compute spend for 1 or 3 yearsFlexible discount across families/RegionsUp to 72%
Spot InstancesUse spare capacity at deep discounts; can be reclaimedFault-tolerant, interruptible batch jobsUp to 90%
Dedicated HostsA physical server dedicated to youBYOL licensing, strict complianceVaries
Dedicated InstancesInstances on hardware isolated to your accountCompliance, isolationVaries

On the Exam: On-Demand = no commitment. RI = specific instance commitment. Savings Plans = flexible commitment. Spot = cheapest but interruptible (2-minute warning). Dedicated = regulatory/licensing.

EC2 Auto Scaling

EC2 Auto Scaling automatically adjusts the number of instances to match demand. It scales out (adds instances) when load rises, scales in (removes instances) when load falls, and replaces unhealthy instances to maintain a desired count. This directly supports the Reliability and Cost Optimization pillars.

Scaling PolicyDescription
Target trackingHold a metric at a target (e.g., average CPU at 50%)
Step scalingAdd/remove capacity in steps tied to alarm thresholds
Scheduled scalingScale on a known schedule (e.g., business hours)
Predictive scalingUse machine learning to forecast demand and scale ahead of it

AWS Lambda (Serverless Compute)

AWS Lambda runs your code in response to events without provisioning or managing servers. You upload a function, choose a runtime, and Lambda handles capacity, patching, scaling, and availability.

FeatureDetail
PricingPay per request plus GB-second of compute duration (billed in 1-ms increments)
Max runtime15 minutes (900 seconds) per invocation
LanguagesPython, Node.js, Java, Go, C#/.NET, Ruby, plus custom runtimes
TriggersAPI Gateway, S3, DynamoDB Streams, SNS, SQS, EventBridge, and more
ScalingAutomatic, to thousands of concurrent executions
ManagementZero servers — no OS patching, no capacity planning

When to use Lambda: event-driven processing (an S3 upload triggers a thumbnail job), serverless API backends (API Gateway + Lambda), stream processing from Kinesis, and short scheduled tasks via EventBridge. Lambda is the wrong choice for jobs longer than 15 minutes — those belong on ECS, Fargate, or AWS Batch.


Container Services

Amazon ECS (Elastic Container Service)

AWS's proprietary container orchestration service for Docker containers. It supports the EC2 launch type (you manage the instances) and the Fargate launch type (serverless — AWS manages the instances).

Amazon EKS (Elastic Kubernetes Service)

A managed Kubernetes control plane. Choose EKS when your team already standardizes on Kubernetes or needs portability across clouds.

AWS Fargate

A serverless compute engine for containers that works with both ECS and EKS. You define CPU/memory for your containers and Fargate provisions the infrastructure — no EC2 instances to patch or scale.

ServiceDescriptionWhen to Use
ECSAWS-native orchestrationDocker workloads, AWS-centric teams
EKSManaged KubernetesKubernetes standard, multi-cloud portability
FargateServerless containers (for ECS or EKS)You do not want to manage EC2 hosts

Other Compute Services

ServiceDescriptionUse Case
AWS Elastic BeanstalkPaaS — deploy web apps without managing infrastructureDevelopers who want to focus on code
Amazon LightsailSimple virtual private server with bundled pricingBlogs, small sites, simple apps
AWS BatchRun batch computing jobs at any scaleData processing, scientific computing
AWS App RunnerFully managed service for containerized web appsDeploy from source or container image
Amazon WorkSpacesManaged virtual desktop (DaaS)Remote workers needing Windows/Linux desktops

On the Exam: When a scenario stresses "no servers to manage," lean toward Lambda or Fargate. When it stresses "full OS control" or "lift-and-shift," lean toward EC2. When it stresses "just deploy my web app," lean toward Elastic Beanstalk.

Test Your Knowledge

A company has a workload that runs continuously 24/7 and is expected to run for the next 3 years. Which EC2 pricing model would provide the MOST cost savings?

A
B
C
D
Test Your Knowledge

Which AWS compute service allows you to run code without provisioning or managing servers?

A
B
C
D
Test Your Knowledge

A company wants to run Docker containers but does not want to manage the underlying EC2 instances. Which combination should they use?

A
B
C
D
Test Your Knowledge

Which EC2 instance family should you choose for a workload that requires high-performance GPUs for machine learning training?

A
B
C
D
Test Your Knowledge

What is the maximum execution time for a single AWS Lambda function invocation?

A
B
C
D