Lesson 264·M24 Cloud & AWS for AI
EC2
OpenLearning Objectives
By the end of this lesson you should be able to:
- Explain the instance types: the CPU, memory, and GPU shapes (L264)
- Explain the AMI: the machine image (L264)
- Explain the storage: the volumes (L264)
- Explain the managed trade: EC2 vs Lambda (L266) vs ECS (L271)
- Explain the AI shape: when the AI workload prefers EC2 (L264)
One-Line Definition
EC2 is the baseline compute (L264) — the virtual servers: the instance types (the CPU, memory, and GPU shapes, L264), the AMI (the machine image, L264), the storage (the EBS volumes, L264), and the placement (the AZ spread, L261) — with the managed trade (the Lambda L266 and the ECS L271 take the servers away, L264) — and the AI shape: the GPU instances (L264) for the training (L365), the managed options for the serving (L264).
The one-sentence interview answer: "EC2 is AWS's virtual server (L264). The shape is the instance type (L264): the CPU instances for the general work, the memory instances for the caches, the GPU instances — like the p and g families — for the training and the fine-tuning (L264, L365). The machine is defined by an AMI — the image with the OS and the software (L264) — and the storage is the EBS volumes attached to it (L264). The trade is managed vs unmanaged (L264): EC2 is the unmanaged baseline — you patch, you scale, you run the fleet (L264); Lambda (L266) takes the servers away for the request handlers (L266); ECS (L271) runs the containers without the servers (L271). The AI shape: the training and the fine-tuning (L365) want the GPU instances (L264) — the raw compute with the drivers (L264); the serving — the chat and the generation endpoints (L233) — prefers the managed options (L266, L271) unless the workload outgrows them (L284). The senior answer names the trade (L264): raw EC2 when the workload needs the machine, managed when it doesn't (L264)."
Mental Model
Think of EC2 as the rental workshop. You rent the space (the instance, L264) with the equipment you choose (the instance type, L264): the workbench (the CPU), the storage racks (the memory), the heavy machinery (the GPU) for the big jobs (the training, L365). The workshop comes with the setup you specify (the AMI, L264) and the storage you attach (the EBS volumes, L264). You manage the workshop yourself (L264): the maintenance, the upgrades, the hours (L264). The alternative is the managed workshop (the Lambda, L266): you bring the task, and the facility runs it — no rental, no maintenance (L266). The AI workshop (L264) rents the heavy machinery (the GPU, L264) for the training (L365) and lets the managed facility (L266) run the daily serving (L264).
the workshop (EC2, L264)
┌────────────────────────────────────────────────────────┐
│ the equipment (the instance type, L264) — CPU, memory, │
│ GPU (L264) │
│ the setup (the AMI, L264) · the storage (the EBS, L264)│
│ the management (L264) — you patch, you scale │
│ the alternatives: the managed facility (L266, L271) │
└────────────────────────────────────────────────────────┘
The mental model is the workshop: the equipment, the setup, the storage, and the management (L264).
Visual Flow — Choosing the Compute
the workload (L264)
│
▼
┌──────────────────────── THE CHOICE (L264) ───────────────────────┐
│ the serving (L233): the chat, the generation endpoints │
│ ┌──────────────┬──────────────────┬─────────────────┐ │
│ │ EC2 (L264) │ Lambda (L266) │ ECS (L271) │ │
│ │ the machine │ the request │ the container │ │
│ │ managed by │ handlers, │ services, │ │
│ │ you │ serverless │ no servers │ │
│ └──────────────┴──────────────────┴─────────────────┘ │
└──────────────────────────┬───────────────────────────────────────┘
▼
┌──────────────────────── THE TRAINING (L365) ─────────────────────┐
│ the GPU instances (L264) — the raw compute with the drivers │
│ the p / g families (L264) — the heavy machinery (L365) │
└──────────────────────────────────────────────────────────────────┘
The flow is the compute choice: the serving on the managed options, the training on the GPU instances (L264).
How It Works — The Compute, Part by Part
- The instance types (L264). The shapes: the general-purpose (the balanced CPU and memory), the compute-optimized (the CPU-heavy work), the memory-optimized (the caches), and the accelerated (the GPUs — the
pandgfamilies) (L264). The type is the workload's match (L264). - The AMI (L264). The machine image — the OS and the software baked in (L264). The AMI makes the fleet reproducible (L264): the same image, the same machine (L264).
- The storage (L264). The EBS volumes — the network-attached disks (L264). The instance's data lives on the volume (L264); the volume is the persistence (L264).
- The placement (L261). The AZ spread (L261) — the instances across the AZs for the availability (L286) (L264).
- The managed trade (L264). The Lambda (L266) and the ECS (L271) take the servers away (L264): the request handlers (L266) and the containers (L271) run without the fleet management (L264).
Note
The managed trade is the senior question (L264). The demo rents a server and calls it done (L264). The architect asks: does this workload need the machine? (L264) — the training (L365) does: the GPU, the drivers, the long-running job (L264). The serving (L233) usually doesn't: the request handler is a Lambda (L266), the container service is ECS (L271), and the servers disappear (L264). EC2 is the baseline the managed options abstract (L264) — not the default (L264).
Real Project Usage
- A training job (L365). The GPU instances (L264) — the
pfamily (L264) — for the fine-tuning (L365), with the spot instances (L285) for the cost (L285). - A legacy service (L264). The long-running process that can't be a Lambda (L264) — the stateful service on EC2 (L264).
- A containerized backend (L271). The ECS tasks (L271) on the EC2 launch type (L271) — the containers on the managed fleet (L271).
- A self-managed database (L264). The RDS alternative (L268) — the database on EC2 when the managed option doesn't fit (L264).
- Anything AWS (L264). The compute options (L264) — the baseline is EC2, the managed options abstract it (L264).
The through-line: the compute is the workload's home — the machine when the workload needs it, the managed options when it doesn't (L264).
Interview Explanation
Say it in four moves:
- The instance. "The virtual server — the type, the AMI, the storage (L264)."
- The types. "CPU, memory, GPU — the
pandgfamilies for the training (L365)." - The trade. "EC2 is the unmanaged baseline; Lambda (L266) and ECS (L271) take the servers away (L264)."
- The AI shape. "The training wants the GPU (L264); the serving wants the managed options (L264)."
Senior-Level Insights
- The compute is a spectrum, not a default (L264). The senior answer places the workload on the spectrum (L264): the training on the GPU instances (L264), the request handlers on the Lambda (L266), the container services on the ECS (L271) — the trade named, not avoided (L264).
- The GPU is the AI-specific instance (L264). The
pandgfamilies (L264) are the training's home (L365) — the raw compute with the drivers (L264). The serving usually doesn't need them (L264). - The spot instance is the cost lever (L285). The interruptible instances (L285) for the batch and the training (L264) — the cost (L285) with the interruption tolerated (L264).
- The AMI is the reproducibility (L264). The image (L264) makes the fleet identical (L264) — the L298 IaC idea, instance-shaped (L264).
- The placement is the availability (L261). The AZ spread (L261) — the instances across the AZs (L286) — the EC2 availability story (L264).
Common Mistakes
- The server as the default (L264). EC2 for every workload (L264) — the Lambda (L266) and the ECS (L271) forgotten (L264).
- The instance type guessed (L264). The CPU instance for the training (L264) — the GPU (L264) is the type (L264).
- The AMI not pinned (L264). The mutable image (L264) — the fleet diverges (L298).
- The data on the instance (L264). The state on the ephemeral disk (L264) — the EBS (L264) and the S3 (L265) are the persistence (L264).
- The single-AZ fleet (L261). All the instances in one AZ (L261) — the availability (L286) lost.
Best Practices
- Place the workload on the spectrum (L264) — the GPU for the training (L365), the managed options for the serving (L266, L271).
- Match the type to the work (L264) — the CPU, the memory, the GPU (L264).
- Pin the AMI (L264) — the reproducible fleet (L298).
- Persist outside the instance (L264) — the EBS (L264), the S3 (L265).
- Spread the AZs (L261) — the availability (L286).
Interview Questions
Q: Walk me through EC2.
A: The virtual server (L264). The instance type — the CPU, memory, and GPU shapes (L264). The AMI — the machine image (L264). The EBS — the storage (L264). And the trade: EC2 is the unmanaged baseline — Lambda (L266) and ECS (L271) take the servers away (L264).
Q: When does an AI workload prefer EC2?
A: When it needs the machine (L264): the training and the fine-tuning (L365) want the GPU instances (L264) — the raw compute with the drivers (L264). The serving — the chat and the generation (L233) — usually prefers the managed options (L266, L271), unless the workload outgrows them (L284).
Q: What's the managed trade?
A: Who runs the servers (L264). EC2 — you patch, scale, and run the fleet (L264). Lambda (L266) — the request handlers, no servers (L266). ECS (L271) — the containers, no servers (L271). The senior answer names the trade for each workload (L264).
Q: What's a GPU instance for?
A: The compute-heavy AI work (L264): the training and the fine-tuning (L365). The
pandgfamilies (L264) carry the GPU with the drivers (L264). The serving usually doesn't need them (L264) — the inference is a Lambda or a container (L266, L271).
Follow-Up Questions
- What are the instance types (L264)?
- What's the AMI (L264)?
- What's the managed trade (L264)?
- When does the AI workload prefer EC2 (L264)?
- What's the spot instance for (L285)?
Comparison Table — The Compute Spectrum
| EC2 (L264) | Lambda (L266) | ECS (L271) | |
|---|---|---|---|
| Unit (L264) | the virtual server | the function | the container |
| Servers (L264) | you run them | none | none |
| AI use (L264) | the training (L365), the legacy | the request handlers (L266) | the container services (L271) |
| Cost (L285) | the running instance | the invocations (L266) | the running tasks (L271) |
The senior read: the spectrum is the answer — the training on the left, the serving on the right (L264).
Code Example — The Compute, Declared
// The compute spectrum, declared (L264).
// THE TRAINING (L365) — the GPU instance (L264), the heavy machinery.
const training = {
type: 'p4d.24xlarge', // the GPU family (L264) — for the training (L365)
ami: 'ami-0c1234567890', // the pinned image (L264) — the reproducible fleet (L298)
storage: { size: 2000, type: 'gp3' }, // the EBS volume (L264)
placement: { azs: ['us-east-1a', 'us-east-1b'] }, // the AZ spread (L261)
lifecycle: 'spot', // the cost lever (L285) — the interruption tolerated (L264)
};
// THE SERVING (L233) — the managed options (L264).
// The request handler: the Lambda (L266) — no servers.
// The container service: the ECS task (L271) — no servers.
const serving = { lambda: true, ecs: true }; // the managed spectrum (L266, L271)
What the reader must SEE — the spectrum, declared:
p4d.24xlarge → the GPU instance — the training's home (L264, L365)
ami pinned → the reproducible fleet (L264, L298)
gp3 + spread → the persistence + the availability (L264, L261)
spot → the cost lever — the interruption tolerated (L285)
lambda / ecs → the serving's managed options (L266, L271)
The machine when the workload needs it; managed when it doesn't.
Tip
The pair that defines the compute: the GPU instance (the training's home, L264) and the managed option (the serving's home, L266, L271). The machine when it's needed, managed when it isn't — the spectrum, not the default (L264).
Performance Notes
- The type is the performance (L264). The CPU, the memory, the GPU (L264) — the type is the workload's match (L264) — the training on the CPU is the hours wasted (L365).
- The GPU is the training's speed (L264). The
pfamily (L264) — the training time (L365) is the GPU's job (L264). - The EBS is the I/O (L264). The volume type and size (L264) — the throughput (L333) is the disk's (L264).
- The spot is the cost (L285). The interruptible instances (L285) — up to 90% off (L285) — for the tolerant workloads (L264).
Debugging Scenarios
| Symptom | First check (L264) | The lever |
|---|---|---|
| The training is slow | The instance type (L264) | The GPU instance (L264) |
| The fleet diverges | The AMI (L264) | The pinned image (L298) |
| The data is lost | The instance store (L264) | The EBS (L264), the S3 (L265) |
| The cost spikes | The running instances (L285) | The spot (L285), the managed options (L264) |
| The AZ failure takes the fleet | The placement (L261) | The AZ spread (L286) |
Quick Revision Notes
- EC2 = the baseline compute (L264): the instance, the AMI, the storage, the trade.
- The types: CPU, memory, GPU (L264) — the
p/gfor the training (L365). - The trade: EC2 unmanaged; Lambda (L266), ECS (L271) managed.
- The AI shape: the GPU for the training (L264), the managed options for the serving (L264).
Cheat Sheet
EC2 = the baseline compute
THE INSTANCE (L264)
the type: general · compute · memory · accelerated (the GPU, L264)
the AMI: the machine image — the reproducible fleet (L298)
the EBS: the network-attached storage (L264)
THE TRADE (L264)
EC2 — you run the servers
Lambda (L266) — the request handlers, no servers
ECS (L271) — the containers, no servers
THE AI SHAPE (L264)
the training (L365) → the GPU instances (L264) — the p / g families
the serving (L233) → the managed options (L266, L271)
the cost → the spot instances (L285) for the tolerant work (L264)
INTERVIEW, 4 MOVES
1 instance "the virtual server — the type, the AMI, the storage (L264)"
2 types "CPU, memory, GPU — the training's home (L365)"
3 trade "EC2 unmanaged; Lambda, ECS managed (L264)"
4 AI shape "the GPU for the training, the managed for the serving (L264)"Key Takeaways
Recap
- EC2 is the baseline compute (L264): the instance types (L264), the AMI (L264), the storage (L264), and the placement (L261)
- The instance types (L264) are the shapes — the CPU, the memory, and the GPU (the
pandgfamilies for the training, L365) - The AMI (L264) is the machine image — the reproducible fleet (L298); the EBS (L264) is the persistence
- The trade is managed vs unmanaged (L264): EC2 runs the servers, Lambda (L266) and ECS (L271) take them away
- The AI shape (L264): the training (L365) wants the GPU instances (L264); the serving (L233) prefers the managed options (L266, L271) — unless the workload outgrows them (L284)
- The senior answer places the workload on the spectrum (L264) — the machine when it's needed, the managed options when it isn't (L264)
Check your understanding
Answer each one out loud. Then rate yourself honestly.
0/8What are the instance types (L264)?
What's the AMI (L264)?
What's the EBS (L264)?
What's the managed trade (L264)?
When does the AI workload prefer EC2 (L264)?
What's the GPU instance for (L365)?
What's the spot instance for (L285)?
What is the compute spectrum (L264)?
A Closing Note — The Workshop, Rented
You now hold the compute: the instance types, the AMI, the storage, and the managed trade — with the GPU for the training and the managed options for the serving. The network has a tenant — and the workload has a home (L264).
Next: the object store behind everything — S3 (L265).