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)
| Full control of a virtual server | Amazon EC2 |
| Run Docker containers, AWS-native | Amazon ECS |
| Run Kubernetes | Amazon EKS |
| Run containers without managing servers | AWS Fargate |
| Run code in response to events, no servers | AWS Lambda |
| Upload code and let AWS deploy it | AWS Elastic Beanstalk |
| Simple, low-cost virtual server or website | Amazon Lightsail |
| Large-scale batch jobs | AWS Batch |
| AWS infrastructure in your own data center | AWS 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
| AMI | Template containing OS and applications used to launch instances; can be AWS-provided, marketplace, or your own |
| Instance type | Combination of vCPU, memory, storage and network capacity |
| Key pair | Public/private key for secure login |
| Security group | Stateful virtual firewall at instance level |
| User data | Bootstrap script run at launch |
| EBS volume | Persistent block storage attached to an instance (Day 4) |
| Instance store | Temporary storage physically attached to the host; lost when the instance stops or terminates |
| Elastic IP | A static public IPv4 address you own until released |
| Tags | Labels (key-value) for organizing and cost tracking |
| Placement groups | Control 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
| Running | Yes | Yes |
| Stopped | No | Yes (EBS volumes remain) |
| Terminated | No | Root 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
| General purpose | Balance of compute, memory, network | T, M (and Mac) | Web servers, small databases, dev/test |
| Compute optimized | High-performance processors | C | Batch processing, gaming servers, scientific modeling, ML inference, HPC |
| Memory optimized | Large datasets in memory | R, X, z | In-memory databases, caches, real-time big data |
| Storage optimized | High, sequential read/write to local storage | I, D, H | NoSQL databases, data warehousing, log processing |
| Accelerated computing | Hardware accelerators (GPU, FPGA, AWS Trainium/Inferentia) | P, G, F, Inf, Trn | Machine learning training, graphics, video |
| HPC optimized | High-performance computing | Hpc | Large 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
| Cluster | Instances close together in one AZ | Lowest latency, high throughput (HPC) |
| Spread | Instances on distinct hardware | Small number of critical instances, reduce correlated failure |
| Partition | Groups of instances on separate racks | Large 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)
| On-Demand | Pay per second (Linux) or per hour, no upfront cost | None | None | New, spiky, short-term, or unpredictable workloads | Highest unit price |
| Reserved Instances (RI) | Commit to instance configuration | 1 or 3 years | ~72% (Standard RI) | Steady-state, predictable workloads | Locked to configuration |
| Savings Plans | Commit to a $/hour spend | 1 or 3 years | ~72% (EC2 Instance SP), ~66% (Compute SP) | Flexible commitment across instance types, Regions (Compute SP), Fargate and Lambda | Must commit spend |
| Spot Instances | Bid on unused EC2 capacity | None | ~90% | Fault-tolerant, flexible, stateless: batch, big data, CI/CD, containers | AWS can reclaim with a 2-minute notice |
| Dedicated Hosts | A physical server fully dedicated to you | On-Demand or 1/3-year reservation | Varies | Server-bound licenses (BYOL), compliance | Most expensive |
| Dedicated Instances | Instances on hardware dedicated to your account | Pay per instance | None | Compliance isolation without host-level control | Costs more |
| Capacity Reservations | Reserve capacity in a specific AZ for any duration | None | No discount | Guarantee capacity for events | Pay 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
| Commit to | Specific instance attributes | Dollar amount per hour |
| Flexibility | Lower | Higher |
| Applies to | EC2 (also RDS, ElastiCache etc. have their own RIs) | EC2, Fargate, Lambda (Compute SP) |
| Discount | Similar | Similar |
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
| Right-sizing | Match instance size to real usage (use Compute Optimizer) |
| Stop idle instances | Schedule dev/test to run only during work hours |
| Use Auto Scaling | Remove capacity when not needed |
| Mix purchase options | Reserved for baseline, On-Demand for peaks, Spot for flexible jobs |
| Choose Graviton (Arm) instances | Better 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)
| Minimum | Fewest instances always running |
| Desired capacity | Number it tries to maintain |
| Maximum | Upper limit (cost safety) |
| Launch template | Defines AMI, type, security group for new instances |
| Target tracking | Keep a metric near a target (for example 50% CPU) |
| Step / simple scaling | Add or remove based on alarm thresholds |
| Scheduled scaling | Scale at known times (Monday 9 AM) |
| Predictive scaling | Uses 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)
| Application Load Balancer (ALB) | Layer 7 | HTTP, HTTPS, gRPC | Web apps, microservices, path- and host-based routing |
| Network Load Balancer (NLB) | Layer 4 | TCP, UDP, TLS | Extreme performance, millions of requests per second, static IP |
| Gateway Load Balancer (GWLB) | Layer 3 | IP | Deploy third-party virtual appliances (firewalls, intrusion detection) |
| Classic Load Balancer (CLB) | 4 and 7 | Legacy | Previous 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
| Amazon ECS (Elastic Container Service) | AWS-native container orchestration for Docker containers | Simple, deeply integrated with AWS |
| Amazon EKS (Elastic Kubernetes Service) | Managed Kubernetes control plane | Choose when you already use Kubernetes or need portability |
| AWS Fargate | Serverless 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 registry | Store, scan, and share images |
| AWS App Runner | Deploy containerized web apps and APIs from source or image with little setup | Simplest container path |
| ECS/EKS on EC2 | Yes (the underlying instances) | Need control, specialized hardware |
| ECS/EKS on Fargate | No | Want 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
| Maximum run time | 15 minutes per invocation |
| Languages | Python, Node.js, Java, .NET, Go, Ruby, custom runtimes, containers |
| Scaling | Automatic, from zero to thousands of concurrent executions |
| Pricing | Per request plus duration x memory; free tier includes 1 million requests and 400,000 GB-seconds per month (Always Free) |
| Common triggers | API Gateway, S3, DynamoDB streams, SQS, SNS, EventBridge schedules |
| Idle cost | Zero 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
| AWS Elastic Beanstalk | PaaS | Upload 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 resources | Developers who want to deploy quickly without learning every service |
| Amazon Lightsail | Simplified IaaS/PaaS bundle | Virtual servers, storage, databases, networking at predictable monthly price | Small websites, blogs, simple apps, learners |
| AWS Batch | Batch processing | Runs batch jobs at any scale, provisions the right compute (can use Spot) | Large asynchronous processing |
| AWS Outposts | Hybrid | AWS-managed hardware in your data center | Low latency to on-premises systems, data residency |
| AWS Wavelength / Local Zones | Edge | Compute near 5G networks or cities | Ultra-low latency |
| AWS Serverless Application Repository / SAM | Serverless tooling | Share and build serverless apps | Awareness |
| EC2 Image Builder | Automation | Build and patch AMIs and container images | Golden images |
| AWS Compute Optimizer | Optimization | ML-based right-sizing recommendations | Cost savings |
Elastic Beanstalk vs CloudFormation vs Lightsail
| Idea | Deploy an application easily | Define infrastructure as code | Simple virtual private server bundle |
| You provide | Code | Template (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
| Spot is for critical databases | Wrong. Spot can be interrupted; use for fault-tolerant jobs |
| Reserved Instances need upfront payment only | Options: All, Partial, or No upfront |
| Stopped instances are free | You still pay for EBS storage |
| Fargate replaces ECS | Fargate is a compute engine for ECS or EKS |
| Lambda has no limits | 15 minute max, memory limits |
| ALB works at Layer 4 | ALB is Layer 7, NLB is Layer 4 |
| Auto Scaling costs extra | The service is free, you pay for resources |
| Dedicated Instance = Dedicated Host | A Host gives visibility of the physical server (sockets and cores) for licensing |
| Elastic Beanstalk hides all resources | You 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
| 1 | Which EC2 purchase option is cheapest for a fault-tolerant batch job? | Spot Instances |
| 2 | Which service runs code without provisioning servers? | AWS Lambda |
| 3 | Which service lets you run containers without managing servers or clusters? | AWS Fargate |
| 4 | Which feature automatically adds EC2 instances when CPU usage rises? | EC2 Auto Scaling |
| 5 | Which load balancer supports path-based routing for HTTP traffic? | Application Load Balancer |
| 6 | Which option fits a steady 3-year workload with the largest discount? | Reserved Instances (Standard) or Savings Plans |
| 7 | Which instance family suits in-memory databases? | Memory optimized (R, X) |
| 8 | Which service deploys an application from uploaded code and manages the infrastructure for you? | AWS Elastic Beanstalk |
| 9 | Which service offers simple virtual servers at a predictable monthly price? | Amazon Lightsail |
| 10 | Which service is a managed Kubernetes offering? | Amazon EKS |
| 11 | What is the maximum execution time of a Lambda function? | 15 minutes |
| 12 | A 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.
Loading article