AWS Builder Center
Day 3: AWS Compute Services

Day 3: AWS Compute Services

Exam domain covered today: Domain 3, Cloud Technology and Services (34%), plus pricing questions that also appear in Domain 4.

What you will learn today

  • Amazon EC2 and core instance concepts
  • Instance types
  • On-Demand, Reserved, Spot, Savings Plans (and other purchase options)
  • Auto Scaling and Elastic Load Balancing
  • Amazon ECS, Amazon EKS, and AWS Fargate
  • AWS Lambda, Elastic Beanstalk, and Lightsail
  • Other compute services worth knowing

1. Choosing a compute service: the big picture

1
2
3
4
5
6
7
8
How much do you want to manage?
|
MOST control <----------------+----------------> LEAST management
| | | |
Amazon EC2 Containers Elastic Beanstalk AWS Lambda
(virtual servers) ECS / EKS (upload code, AWS (run code on
(+ Fargate = handles the platform) events, no servers)
no servers)
NeedService
Full control of a virtual serverAmazon EC2
Run Docker containers, AWS-nativeAmazon ECS
Run KubernetesAmazon EKS
Run containers without managing serversAWS Fargate
Run code in response to events, no serversAWS Lambda
Upload code and let AWS deploy itAWS Elastic Beanstalk
Simple, low-cost virtual server or websiteAmazon Lightsail
Large-scale batch jobsAWS Batch
AWS infrastructure in your own data centerAWS Outposts

2. Amazon EC2 (Elastic Compute Cloud)

EC2 provides resizable virtual servers (instances) in the cloud (IaaS). You pay for compute capacity while instances run.

What you choose when launching an instance

1
2
3
4
5
6
7
8
9
Launch instance
|-- AMI (Amazon Machine Image) = OS + software template
|-- Instance type = CPU, memory, network (e.g., t3.micro)
|-- Key pair = SSH / RDP login
|-- Network settings = VPC, subnet (AZ), public IP
|-- Security group = virtual firewall (allow rules)
|-- Storage = EBS volume(s) / instance store
|-- IAM role (instance profile) = permissions for the app
|-- User data (optional) = script that runs at first boot
ConceptMeaning
AMITemplate containing OS and applications used to launch instances; can be AWS-provided, marketplace, or your own
Instance typeCombination of vCPU, memory, storage and network capacity
Key pairPublic/private key for secure login
Security groupStateful virtual firewall at instance level
User dataBootstrap script run at launch
EBS volumePersistent block storage attached to an instance (Day 4)
Instance storeTemporary storage physically attached to the host; lost when the instance stops or terminates
Elastic IPA static public IPv4 address you own until released
TagsLabels (key-value) for organizing and cost tracking
Placement groupsControl how instances are placed (see below)

Instance lifecycle and billing

1
2
3
4
pending --> running --> stopping --> stopped --> (start again) --> running
|
+--> shutting-down --> terminated (gone for good)
running --> stop-hibernate (RAM saved to disk) --> stopped
StateCompute charge?Storage (EBS) charge?
RunningYesYes
StoppedNoYes (EBS volumes remain)
TerminatedNoRoot volume deleted by default; other volumes depend on settings
Exam tip: Stopped instance = no compute charges but you still pay for attached EBS storage and Elastic IPs that are not in use.

Instance type families

FamilyOptimized forLettersUse cases
General purposeBalance of compute, memory, networkT, M (and Mac)Web servers, small databases, dev/test
Compute optimizedHigh-performance processorsCBatch processing, gaming servers, scientific modeling, ML inference, HPC
Memory optimizedLarge datasets in memoryR, X, zIn-memory databases, caches, real-time big data
Storage optimizedHigh, sequential read/write to local storageI, D, HNoSQL databases, data warehousing, log processing
Accelerated computingHardware accelerators (GPU, FPGA, AWS Trainium/Inferentia)P, G, F, Inf, TrnMachine learning training, graphics, video
HPC optimizedHigh-performance computingHpcLarge simulations
Instance name anatomy: m5.large = family m, generation 5, size large. Larger sizes = more vCPU and memory.
Memory trick: Compute = CPU. R = RAM. I = I/O. P/G = GPU and graphics. T/M = Mixed, general.

Placement groups

TypeBehaviorUse when
ClusterInstances close together in one AZLowest latency, high throughput (HPC)
SpreadInstances on distinct hardwareSmall number of critical instances, reduce correlated failure
PartitionGroups of instances on separate racksLarge distributed systems (Hadoop, Cassandra)

3. EC2 pricing options (guaranteed exam content)

1
2
3
4
5
6
7
8
9
10
How predictable is your workload?
|
+------------------+-----------------------+
| | |
Unpredictable / Steady for 1-3 years, Flexible, can be
short-term known usage interrupted
| | |
ON-DEMAND RESERVED INSTANCES / SPOT INSTANCES
(no commitment) SAVINGS PLANS (up to ~90% off)
(up to ~72% off)
OptionHow it worksCommitmentDiscount (up to)Best forWatch out
On-DemandPay per second (Linux) or per hour, no upfront costNoneNoneNew, spiky, short-term, or unpredictable workloadsHighest unit price
Reserved Instances (RI)Commit to instance configuration1 or 3 years~72% (Standard RI)Steady-state, predictable workloadsLocked to configuration
Savings PlansCommit to a $/hour spend1 or 3 years~72% (EC2 Instance SP), ~66% (Compute SP)Flexible commitment across instance types, Regions (Compute SP), Fargate and LambdaMust commit spend
Spot InstancesBid on unused EC2 capacityNone~90%Fault-tolerant, flexible, stateless: batch, big data, CI/CD, containersAWS can reclaim with a 2-minute notice
Dedicated HostsA physical server fully dedicated to youOn-Demand or 1/3-year reservationVariesServer-bound licenses (BYOL), complianceMost expensive
Dedicated InstancesInstances on hardware dedicated to your accountPay per instanceNoneCompliance isolation without host-level controlCosts more
Capacity ReservationsReserve capacity in a specific AZ for any durationNoneNo discountGuarantee capacity for eventsPay even when unused
Reserved Instance payment options: All Upfront (biggest discount), Partial Upfront, No Upfront (smallest discount). RI types: Standard (largest discount, limited changes) vs Convertible (can change instance family, smaller discount).
Reserved Instances vs Savings Plans
Reserved InstancesSavings Plans
Commit toSpecific instance attributesDollar amount per hour
FlexibilityLowerHigher
Applies toEC2 (also RDS, ElastiCache etc. have their own RIs)EC2, Fargate, Lambda (Compute SP)
DiscountSimilarSimilar
Analogy: On-Demand is a taxi. Reserved Instances and Savings Plans are a monthly metro pass. Spot is a heavily discounted standby ticket that can be cancelled when the airline needs the seat. A Dedicated Host is renting a whole building.
Exam clue: "Can tolerate interruptions" or "flexible start and end times" = Spot. "Steady-state, 1 or 3 years" = Reserved or Savings Plans. "Short-term, unpredictable, cannot be interrupted" = On-Demand. "Bring your own server-bound license" = Dedicated Host.

Other ways to save on EC2

TechniqueExplanation
Right-sizingMatch instance size to real usage (use Compute Optimizer)
Stop idle instancesSchedule dev/test to run only during work hours
Use Auto ScalingRemove capacity when not needed
Mix purchase optionsReserved for baseline, On-Demand for peaks, Spot for flexible jobs
Choose Graviton (Arm) instancesBetter price performance for supported workloads

4. EC2 Auto Scaling

Auto Scaling groups (ASG) automatically add or remove EC2 instances to match demand, and replace unhealthy ones.
1
2
3
Traffic rises ----> Auto Scaling adds instances (scale OUT)
min=2 [vm][vm] --> [vm][vm][vm][vm] <-- desired / max=6
Traffic falls ----> Auto Scaling removes instances (scale IN)
SettingMeaning
MinimumFewest instances always running
Desired capacityNumber it tries to maintain
MaximumUpper limit (cost safety)
Launch templateDefines AMI, type, security group for new instances
Scaling policyDescription
Target trackingKeep a metric near a target (for example 50% CPU)
Step / simple scalingAdd or remove based on alarm thresholds
Scheduled scalingScale at known times (Monday 9 AM)
Predictive scalingUses machine learning to forecast and pre-scale
Benefits: elasticity, cost savings, high availability (spread across AZs, health checks).
Exam tip: Auto Scaling itself is free; you pay for the instances it launches. Scale out/in = number of instances. Scale up/down = size of an instance.

5. Elastic Load Balancing (ELB)

ELB distributes incoming traffic across multiple targets (EC2, containers, IPs, Lambda) in multiple AZs, and sends traffic only to healthy targets.
1
2
3
Users --> [ Load Balancer ] --+--> EC2 in AZ-a
+--> EC2 in AZ-b
+--> EC2 in AZ-c (unhealthy targets are skipped)
TypeOSI layerProtocolBest for
Application Load Balancer (ALB)Layer 7HTTP, HTTPS, gRPCWeb apps, microservices, path- and host-based routing
Network Load Balancer (NLB)Layer 4TCP, UDP, TLSExtreme performance, millions of requests per second, static IP
Gateway Load Balancer (GWLB)Layer 3IPDeploy third-party virtual appliances (firewalls, intrusion detection)
Classic Load Balancer (CLB)4 and 7LegacyPrevious generation, not recommended for new apps
Auto Scaling + ELB together = high availability and elasticity: the load balancer spreads traffic, Auto Scaling changes the number of targets.

6. Containers: ECS, EKS, Fargate, ECR

1
2
3
Container = app + its dependencies, packaged to run the same everywhere

Build image --> store in ECR --> run with ECS or EKS --> on EC2 or Fargate
ServiceWhat it isKey points
Amazon ECS (Elastic Container Service)AWS-native container orchestration for Docker containersSimple, deeply integrated with AWS
Amazon EKS (Elastic Kubernetes Service)Managed Kubernetes control planeChoose when you already use Kubernetes or need portability
AWS FargateServerless compute engine for containers (works with ECS and EKS)No servers or clusters to manage; pay for vCPU and memory used
Amazon ECR (Elastic Container Registry)Fully managed Docker image registryStore, scan, and share images
AWS App RunnerDeploy containerized web apps and APIs from source or image with little setupSimplest container path
Launch typeYou manage servers?Use when
ECS/EKS on EC2Yes (the underlying instances)Need control, specialized hardware
ECS/EKS on FargateNoWant simplicity, no server management
Exam trap: Fargate is not an orchestrator. It is the serverless compute that runs containers for ECS or EKS.

7. AWS Lambda (serverless compute)

Lambda runs your code in response to events with no servers to provision or manage. You pay only for requests and compute duration (billed in milliseconds).
1
2
3
Event source Lambda function Result
S3 upload / API call / ---> [ your code runs ] ---> write to DynamoDB, send
schedule / SQS message (auto-scales) notification, resize image
FactDetail
Maximum run time15 minutes per invocation
LanguagesPython, Node.js, Java, .NET, Go, Ruby, custom runtimes, containers
ScalingAutomatic, from zero to thousands of concurrent executions
PricingPer request plus duration x memory; free tier includes 1 million requests and 400,000 GB-seconds per month (Always Free)
Common triggersAPI Gateway, S3, DynamoDB streams, SQS, SNS, EventBridge schedules
Idle costZero when not running
When Lambda is a poor fit: long-running jobs over 15 minutes, applications needing a persistent OS-level connection or special hardware.
Analogy: Lambda is a vending machine: nothing happens until someone presses a button, and you pay only per item dispensed.

8. Elastic Beanstalk, Lightsail and other compute

ServiceTypeWhat it doesUse when
AWS Elastic BeanstalkPaaSUpload your code (Java, .NET, Node.js, Python, PHP, Ruby, Go, Docker); Beanstalk provisions EC2, load balancer, Auto Scaling, monitoring. You still own and can access the resources; you pay only for the underlying resourcesDevelopers who want to deploy quickly without learning every service
Amazon LightsailSimplified IaaS/PaaS bundleVirtual servers, storage, databases, networking at predictable monthly priceSmall websites, blogs, simple apps, learners
AWS BatchBatch processingRuns batch jobs at any scale, provisions the right compute (can use Spot)Large asynchronous processing
AWS OutpostsHybridAWS-managed hardware in your data centerLow latency to on-premises systems, data residency
AWS Wavelength / Local ZonesEdgeCompute near 5G networks or citiesUltra-low latency
AWS Serverless Application Repository / SAMServerless toolingShare and build serverless appsAwareness
EC2 Image BuilderAutomationBuild and patch AMIs and container imagesGolden images
AWS Compute OptimizerOptimizationML-based right-sizing recommendationsCost savings
Elastic Beanstalk vs CloudFormation vs Lightsail
Elastic BeanstalkCloudFormationLightsail
IdeaDeploy an application easilyDefine infrastructure as codeSimple virtual private server bundle
You provideCodeTemplate (JSON/YAML)Pick a blueprint

9. Compute decision flowchart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Need to run code or an app?
|
Event-driven, short (<15 min), no servers? ----yes---> LAMBDA
| no
Containerized?
|-- yes --> Want to avoid servers? --yes--> FARGATE (with ECS or EKS)
| | no --> ECS or EKS on EC2
| no
Want AWS to handle deployment of my code? ---yes---> ELASTIC BEANSTALK
| no
Simple, low cost, predictable price? ---------yes---> LIGHTSAIL
| no
Need full OS-level control? -------------------yes---> EC2
|
Batch processing at scale? --------------------yes---> AWS BATCH

10. Exam traps for Day 3

TrapCorrect thinking
Spot is for critical databasesWrong. Spot can be interrupted; use for fault-tolerant jobs
Reserved Instances need upfront payment onlyOptions: All, Partial, or No upfront
Stopped instances are freeYou still pay for EBS storage
Fargate replaces ECSFargate is a compute engine for ECS or EKS
Lambda has no limits15 minute max, memory limits
ALB works at Layer 4ALB is Layer 7, NLB is Layer 4
Auto Scaling costs extraThe service is free, you pay for resources
Dedicated Instance = Dedicated HostA Host gives visibility of the physical server (sockets and cores) for licensing
Elastic Beanstalk hides all resourcesYou can still access the created EC2, ELB, etc.

11. Key takeaways

  • EC2 = virtual servers. Know the five instance families and the pricing options.
  • On-Demand (flexible), Reserved / Savings Plans (commit for savings), Spot (cheapest, interruptible), Dedicated Host (physical server).
  • Auto Scaling + ELB give elasticity and high availability.
  • ECS/EKS orchestrate containers; Fargate removes server management; Lambda runs functions serverlessly.
  • Beanstalk = easiest app deployment. Lightsail = simplest low-cost servers.

12. Day 3 practice questions

#QuestionAnswer
1Which EC2 purchase option is cheapest for a fault-tolerant batch job?Spot Instances
2Which service runs code without provisioning servers?AWS Lambda
3Which service lets you run containers without managing servers or clusters?AWS Fargate
4Which feature automatically adds EC2 instances when CPU usage rises?EC2 Auto Scaling
5Which load balancer supports path-based routing for HTTP traffic?Application Load Balancer
6Which option fits a steady 3-year workload with the largest discount?Reserved Instances (Standard) or Savings Plans
7Which instance family suits in-memory databases?Memory optimized (R, X)
8Which service deploys an application from uploaded code and manages the infrastructure for you?AWS Elastic Beanstalk
9Which service offers simple virtual servers at a predictable monthly price?Amazon Lightsail
10Which service is a managed Kubernetes offering?Amazon EKS
11What is the maximum execution time of a Lambda function?15 minutes
12A company has per-socket software licensing. Which EC2 option fits?Dedicated Hosts
Up next on Day 4: Storage and Databases: S3, EBS, EFS, FSx, RDS, Aurora, DynamoDB, ElastiCache, Redshift.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article