Compute Services (EC2, Lambda, Containers)
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
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
| Family | Optimized For | Types | Common Use Cases |
|---|---|---|---|
| General Purpose (M, T) | Balanced compute/memory/network | t3.micro, m6i.large | Web servers, dev/test, small databases |
| Compute Optimized (C) | High vCPU-to-memory ratio | c6i.large, c7g.xlarge | Batch processing, gaming servers, ML inference |
| Memory Optimized (R, X) | Large in-memory datasets | r6i.large, x2gd.xlarge | In-memory databases, SAP HANA, big data analytics |
| Storage Optimized (I, D) | High sequential I/O, local NVMe | i3.large, d3.xlarge | OLTP databases, data warehousing, Hadoop |
| Accelerated Computing (P, G) | GPU / hardware accelerators | p3.xlarge, g5.xlarge | ML training, video rendering, scientific computing |
EC2 Purchasing Options
| Option | Max Savings | Commitment | Interruption | Best For |
|---|---|---|---|---|
| On-Demand | 0% | None | Never | Variable, unpredictable workloads; dev/test |
| Reserved (Standard) | Up to 72% | 1 or 3 yr | Never | Steady-state known workloads |
| Reserved (Convertible) | Up to 54% | 1 or 3 yr | Never | When you might change instance family |
| Compute Savings Plans | Up to 66% | 1 or 3 yr ($/hr) | Never | Flexible — any family, size, region, OS |
| Spot Instances | Up to 90% | None | YES — 2-min warning | Batch jobs, data analysis, fault-tolerant apps |
| Dedicated Hosts | Varies | Optional 1/3 yr | Never | BYOL licenses, regulatory compliance |
| Dedicated Instances | Varies | On-Demand or RI | Never | Physical 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.
Lambda key facts:
| Feature | Detail |
|---|---|
| Languages | Node.js, Python, Java, Go, .NET, Ruby, custom runtimes |
| Max execution time | 15 minutes per invocation |
| Memory | 128 MB to 10 GB (CPU scales proportionally) |
| Pricing | Per request + duration in GB-seconds; generous free tier |
| Scaling | Automatic — thousands of concurrent executions |
| State | Stateless — no persistent local state between invocations |
4. Container Services
Containers package code with its dependencies into a portable unit that runs consistently anywhere.
| Service | Description |
|---|---|
| Amazon ECS | AWS-native Docker container orchestration; simpler to operate |
| Amazon EKS | AWS-managed Kubernetes; use when you need Kubernetes compatibility |
| Amazon ECR | Private container image registry; integrated with ECS and EKS |
| AWS Fargate | Serverless 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
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:
| Type | Layer | Protocol | Use Case |
|---|---|---|---|
| ALB (Application LB) | Layer 7 | HTTP / HTTPS | Web apps, microservices, path and host-based routing |
| NLB (Network LB) | Layer 4 | TCP / UDP | Ultra-low latency, static IPs, gaming, IoT, VoIP |
| GLB (Gateway LB) | Layer 3 | IP packets | Deploy third-party firewalls and IDS/IPS appliances |
9. CLF-C02 Quick Reference
| Topic | Key Fact |
|---|---|
| EC2 | Virtual servers; full OS control; you patch the guest OS |
| On-Demand | No commitment; full price; most flexible |
| Reserved Instances | 1 or 3 yr; up to 72% savings; steady-state workloads |
| Spot Instances | Up to 90% savings; can be interrupted with 2-min warning |
| Savings Plans | Flexible $/hr commitment; up to 66% savings |
| Dedicated Hosts | Physical server; bring your own license; compliance |
| Lambda | Serverless; event-triggered; max 15 min; auto-scales |
| Fargate | Serverless containers; no EC2 nodes; works with ECS and EKS |
| ECS | AWS-native container orchestration |
| EKS | AWS-managed Kubernetes |
| ECR | Container image registry |
| Elastic Beanstalk | Deploy web apps; AWS manages infrastructure; you manage code |
| Lightsail | Simple predictable-cost VPS for small workloads |
| Auto Scaling | Adjusts EC2 instance count based on demand; maintains healthy instances |
| ALB | Layer 7; HTTP/HTTPS; path-based routing |
| NLB | Layer 4; TCP/UDP; ultra-low latency; static IPs |
Practice Questions10
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.
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.
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.
Q4. What is the maximum execution duration for a single AWS Lambda function invocation?
Select one answer before revealing.
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.
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.
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.
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.
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.
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.