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.
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
| Family | Optimized For | Examples | Use Cases |
|---|---|---|---|
| General Purpose (T, M) | Balanced compute, memory, networking | t3.micro, m6i.large | Web servers, code repos, small/medium databases |
| Compute Optimized (C) | High-performance processors | c6i.xlarge | Batch processing, gaming servers, scientific modeling, HPC |
| Memory Optimized (R, X) | Large in-memory datasets | r6i.large, x2idn.large | In-memory databases (SAP HANA), real-time big-data analytics |
| Storage Optimized (I, D) | High sequential read/write to local disk | i4i.large, d3.xlarge | Data warehousing, distributed file systems, NoSQL |
| Accelerated Computing (P, G) | Hardware accelerators (GPUs) | p5.48xlarge, g5.xlarge | Machine 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 Model | Description | Best For | Savings vs. On-Demand |
|---|---|---|---|
| On-Demand | Pay per second (60-sec min, Linux) with no commitment | Short-term, spiky, first-time workloads | Baseline |
| Reserved Instances (RI) | 1- or 3-year commitment to a specific instance type | Steady-state, predictable workloads | Up to 72% |
| Savings Plans | Commit to a $/hour compute spend for 1 or 3 years | Flexible discount across families/Regions | Up to 72% |
| Spot Instances | Use spare capacity at deep discounts; can be reclaimed | Fault-tolerant, interruptible batch jobs | Up to 90% |
| Dedicated Hosts | A physical server dedicated to you | BYOL licensing, strict compliance | Varies |
| Dedicated Instances | Instances on hardware isolated to your account | Compliance, isolation | Varies |
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 Policy | Description |
|---|---|
| Target tracking | Hold a metric at a target (e.g., average CPU at 50%) |
| Step scaling | Add/remove capacity in steps tied to alarm thresholds |
| Scheduled scaling | Scale on a known schedule (e.g., business hours) |
| Predictive scaling | Use 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.
| Feature | Detail |
|---|---|
| Pricing | Pay per request plus GB-second of compute duration (billed in 1-ms increments) |
| Max runtime | 15 minutes (900 seconds) per invocation |
| Languages | Python, Node.js, Java, Go, C#/.NET, Ruby, plus custom runtimes |
| Triggers | API Gateway, S3, DynamoDB Streams, SNS, SQS, EventBridge, and more |
| Scaling | Automatic, to thousands of concurrent executions |
| Management | Zero 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.
| Service | Description | When to Use |
|---|---|---|
| ECS | AWS-native orchestration | Docker workloads, AWS-centric teams |
| EKS | Managed Kubernetes | Kubernetes standard, multi-cloud portability |
| Fargate | Serverless containers (for ECS or EKS) | You do not want to manage EC2 hosts |
Other Compute Services
| Service | Description | Use Case |
|---|---|---|
| AWS Elastic Beanstalk | PaaS — deploy web apps without managing infrastructure | Developers who want to focus on code |
| Amazon Lightsail | Simple virtual private server with bundled pricing | Blogs, small sites, simple apps |
| AWS Batch | Run batch computing jobs at any scale | Data processing, scientific computing |
| AWS App Runner | Fully managed service for containerized web apps | Deploy from source or container image |
| Amazon WorkSpaces | Managed 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.
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?