Compute: Amazon EC2

Virtual servers in the cloud — instance types, pricing options, and the EC2 vocabulary every other service builds on.

10 min read

Amazon EC2 (Elastic Compute Cloud) provides resizable virtual servers called instances. It's the classic IaaS service: you pick the OS (via an AMI — Amazon Machine Image), the hardware profile (instance type), and you manage everything from the OS up.

Instance type families

FamilyOptimized forExample workload
General purpose (t3, m7)Balanced CPU/memoryWeb servers, small databases
Compute optimized (c7)High CPUBatch processing, gaming servers, encoding
Memory optimized (r7, x2)Large RAMIn-memory caches, big databases, real-time analytics
Storage optimized (i4, d3)Fast local disk I/OData warehousing, high-frequency databases
Accelerated computing (p5, g6)GPUs / acceleratorsMachine learning training, graphics

EC2 pricing options

OptionDiscountBest forCatch
On-DemandNone (baseline)Unpredictable, short-term, spiky workloadsMost expensive per hour
Reserved Instances (1 or 3 yr)Up to ~72%Steady-state workloads (e.g., a database that runs 24/7)Commitment to instance family/Region
Savings Plans (1 or 3 yr)Up to ~72%Steady spend with flexibility across instance types (and Fargate/Lambda)Commit to $/hour, not instances
Spot InstancesUp to ~90%Fault-tolerant, interruptible jobs: batch, CI, big dataAWS can reclaim with a 2-minute warning
Dedicated HostsPremium priceCompliance/licensing that requires a physical server to yourselfMost expensive option
Exam tip

Pricing scenarios are guaranteed on the exam: 24/7 steady workload → Reserved/Savings Plans; can be interrupted → Spot; unpredictable/short-term → On-Demand; server-bound software licenses or strict tenancy rules → Dedicated Hosts.

Essentials that orbit EC2

Key points

  • AMI — the template (OS + software) an instance launches from; you can create your own for repeatable builds.
  • Security group — instance-level virtual firewall; stateful; allows rules only.
  • Key pair — SSH credentials for connecting to Linux instances.
  • EC2 Instance Connect / Session Manager — browser-based access without managing SSH keys (Session Manager needs no open ports).
  • Tenancy — shared (default), dedicated instance, or dedicated host.
Think of it like this

Choosing EC2 options is like renting vehicles: On-Demand is a taxi (pay per trip), Reserved is a 3-year lease (cheaper monthly), Spot is a standby airline ticket (huge discount, might get bumped), and a Dedicated Host is buying out the whole limo — nobody else rides.

Knowledge check
Question 1 of 4

A nightly batch job can tolerate interruptions and restarts. Which EC2 purchasing option minimizes its cost?