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.
AWS Compute Services
Quick Answer: AWS compute services range from full virtual servers (EC2) to fully serverless (Lambda). Know when to use each: EC2 for full OS control, Lambda for event-driven code, ECS/EKS for containers, Elastic Beanstalk for managed web apps, and Fargate for serverless containers.
Amazon EC2 (Elastic Compute Cloud)
Amazon EC2 is the foundational compute service that provides resizable virtual servers (called instances) in the cloud. It is the most widely used AWS compute service and the core of the IaaS model.
EC2 Key Features
- Full control over the operating system (Linux, Windows, macOS)
- Multiple instance types optimized for different workloads
- Flexible pricing models (On-Demand, Reserved, Spot, Dedicated)
- Security Groups for firewall control
- Elastic IP addresses for static public IPv4 addresses
- Instance store and EBS volumes for storage
EC2 Instance Families
| Family | Optimized For | Examples | Use Cases |
|---|---|---|---|
| General Purpose (T, M) | Balanced compute, memory, networking | t3.micro, m6i.large | Web servers, code repos, small databases |
| Compute Optimized (C) | High-performance processors | c6i.xlarge | Batch processing, gaming servers, HPC |
| Memory Optimized (R, X) | Large in-memory datasets | r6i.large, x2idn.large | In-memory databases, real-time big data analytics |
| Storage Optimized (I, D) | High sequential read/write to local storage | i3.large, d2.xlarge | Data warehousing, distributed file systems |
| Accelerated Computing (P, G) | Hardware accelerators (GPUs) | p4d.24xlarge, g5.xlarge | Machine learning training, graphics rendering |
On the Exam: You do NOT need to memorize specific instance sizes or prices. Know the instance families and their use cases: T/M = general, C = compute, R/X = memory, I/D = storage, P/G = GPU/accelerated.
EC2 Pricing Models
| Pricing Model | Description | Best For | Savings vs. On-Demand |
|---|---|---|---|
| On-Demand | Pay by the second/hour with no commitment | Short-term, unpredictable workloads | Baseline (no savings) |
| Reserved Instances (RI) | 1-year or 3-year commitment for significant discounts | Steady-state, predictable workloads | Up to 72% |
| Savings Plans | Commitment to consistent compute usage ($/hour) | Flexible reserved pricing across instance families | Up to 72% |
| Spot Instances | Bid on unused EC2 capacity at steep discounts | Fault-tolerant, flexible workloads | Up to 90% |
| Dedicated Hosts | Physical server dedicated to your use | Compliance, licensing requirements | Varies |
| Dedicated Instances | Instances on hardware dedicated to your account | Compliance requirements | Varies |
On the Exam: Key pricing distinctions: On-Demand = no commitment, RI = specific instance commitment, Savings Plans = flexible commitment, Spot = cheapest but can be interrupted, Dedicated = regulatory compliance.
EC2 Auto Scaling
EC2 Auto Scaling automatically adjusts the number of EC2 instances to match demand:
- Scale out — Add instances when demand increases
- Scale in — Remove instances when demand decreases
- Maintains desired count — Automatically replaces unhealthy instances
Scaling policies:
| Policy | Description |
|---|---|
| Target tracking | Maintain a specific metric (e.g., CPU at 50%) |
| Step scaling | Scale in steps based on alarm thresholds |
| Scheduled scaling | Scale based on predictable patterns (e.g., business hours) |
| Predictive scaling | Uses ML to predict demand and scale proactively |
AWS Lambda (Serverless Compute)
AWS Lambda is a serverless compute service that runs your code in response to events without provisioning or managing servers.
| Feature | Detail |
|---|---|
| Pricing | Pay per request and compute duration (millisecond billing) |
| Max runtime | 15 minutes per invocation |
| Languages | Python, Node.js, Java, Go, C#, Ruby, custom runtimes |
| Triggers | API Gateway, S3, DynamoDB, SNS, SQS, CloudWatch Events, and more |
| Scaling | Automatic — scales to thousands of concurrent executions |
| Management | Zero server management (no OS patching, no capacity planning) |
When to use Lambda:
- Event-driven processing (file upload to S3 triggers processing)
- API backends (API Gateway + Lambda)
- Data processing (stream processing from Kinesis)
- Scheduled tasks (cron-like jobs with EventBridge)
- Short-duration tasks (under 15 minutes)
Container Services
Amazon ECS (Elastic Container Service)
AWS's proprietary container orchestration service for running Docker containers. Supports both EC2 launch type (you manage the instances) and Fargate launch type (serverless).
Amazon EKS (Elastic Kubernetes Service)
A managed Kubernetes service for running Kubernetes clusters on AWS. Choose EKS if your organization already uses Kubernetes.
AWS Fargate
A serverless compute engine for containers that works with both ECS and EKS. You do not manage servers — just define your containers and Fargate handles the infrastructure.
| Service | Description | When to Use |
|---|---|---|
| ECS | AWS-native container orchestration | Docker containers, AWS-ecosystem preference |
| EKS | Managed Kubernetes | Kubernetes-standard, multi-cloud portability |
| Fargate | Serverless containers (for ECS or EKS) | Do not want to manage EC2 instances for containers |
Other Compute Services
| Service | Description | Use Case |
|---|---|---|
| AWS Elastic Beanstalk | PaaS — deploy web apps without managing infrastructure | Developers who want to focus on code, not infrastructure |
| Amazon Lightsail | Simple VPS with pre-configured apps | Small blogs, websites, simple applications |
| AWS Batch | Run batch computing jobs at any scale | Large-scale data processing, scientific computing |
| AWS App Runner | Fully managed service for containerized web apps | Deploy containers from source code or image |
| Amazon WorkSpaces | Managed virtual desktop (DaaS) | Remote workers needing Windows or Linux desktops |
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?
Which AWS compute service allows you to run code without provisioning or managing servers?
A company wants to run Docker containers but does not want to manage the underlying EC2 instances. Which combination should they use?
Which EC2 instance family should you choose for a workload that requires high-performance GPUs for machine learning training?
What is the maximum execution time for a single AWS Lambda function invocation?