Prerequisites
- An AWS account
- Basic familiarity with launching an EC2 instance from the console or CLI
What You'll Learn
- Decode an instance type string into family, generation, capability, and size
- Match a workload to the right instance family (general purpose, compute, memory, storage optimized)
- Compare On-Demand, Reserved Instances, Savings Plans, and Spot on cost and risk
- Identify workloads where Spot is safe to use and where it isn't
Theory
Every EC2 instance type name encodes four pieces of information in a fixed pattern: family, generation, optional capability letter, and size.
m6g.xlarge decoded: general-purpose family, 6th generation, Graviton (ARM) processor, xlarge size
Instance families by workload
| Family prefix | Optimized for | Example use case |
|---|---|---|
| t, m | General purpose (balanced CPU:RAM) | Web servers, small databases |
| c | Compute optimized (high CPU:RAM ratio) | Batch processing, video encoding |
| r, x | Memory optimized (high RAM:CPU ratio) | In-memory caches, large databases |
| i, d | Storage optimized (high-speed local NVMe) | Data warehousing, distributed filesystems |
| g, p | Accelerated computing (GPU) | ML training/inference, rendering |
Purchasing options
On-Demand — pay per second, no commitment, highest unit price. Reserved Instances — commit to a specific instance family/region for 1 or 3 years for up to ~72% off, fairly rigid. Savings Plans — commit to a dollar/hour spend instead of a specific instance, discount applies automatically across EC2/Fargate/Lambda usage, more flexible than RIs. Spot — bid on spare AWS capacity for up to ~90% off, but the instance can be reclaimed with a 2-minute warning at any time.
Architecture
A common cost-optimized production pattern splits a fleet across purchasing options: baseline steady-state capacity on a Savings Plan, burst/scale-out capacity on-demand, and fully interruption- tolerant batch workloads on Spot — often coordinated through a single Auto Scaling Group with mixed instance policies so AWS automatically fills capacity across whichever option is available.
Hands-On Lab
Compare pricing and launch a Spot instance from the CLI:
# List current On-Demand prices for a family in your region (requires the Price List API / a tool like ec2-instances.info for a quick read)
aws ec2 describe-instance-types --instance-types m6i.large c6i.large r6i.large \
--query 'InstanceTypes[].[InstanceType,VCpuInfo.DefaultVCpus,MemoryInfo.SizeInMiB]' \
--output table
# Request a Spot instance directly (note: request can be denied if no capacity is available)
aws ec2 run-instances \
--image-id ami-0123456789abcdef0 \
--instance-type c6i.large \
--instance-market-options '{"MarketType":"spot","SpotOptions":{"MaxPrice":"0.05","SpotInstanceType":"one-time"}}' \
--key-name my-key \
--count 1
# Check Spot interruption history/likelihood before committing a workload to it
aws ec2 describe-spot-price-history \
--instance-types c6i.large \
--product-descriptions "Linux/UNIX" \
--max-results 5Best Practices
Right-size before committing to a discount
A 3-year Reserved Instance on an over-provisioned instance locks in waste for three years. Use CloudWatch utilization data (or Compute Optimizer's recommendations) to right-size first, then commit.Use Spot for anything stateless and restartable
CI/CD build agents, batch jobs, and horizontally-scaled stateless web tiers behind a load balancer tolerate Spot interruption well — the Auto Scaling Group just replaces the reclaimed instance.Common Mistakes
Putting a stateful database on Spot
A Spot interruption gives only a 2-minute warning — enough time to drain a stateless web server, not enough to safely fail over a single-instance database with no replica. Keep primary databases on On-Demand or Reserved capacity.Comparing instance types by vCPU count alone
A vCPU on a compute-optimized c-family instance and a burstable t-family instance aren't equivalent — t-family instances use CPU credits and throttle under sustained load. Compare using actual benchmarks or AWS's published relative performance, not vCPU count alone.Troubleshooting
Spot request stuck in "pending": the requested instance type/AZ combination has no spare capacity right now — check describe-spot-price-history for that type across multiple AZs, or use Spot Fleet / Auto Scaling with multiple instance types to widen the pool of acceptable capacity.
Reserved Instance not applying its discount:RIs match on instance family, region, tenancy, and platform — a mismatch on any of these (e.g. reserving in us-east-1 but running in us-east-2, or a size mismatch with regional RIs, which do allow size-flexibility within the same family/generation) silently leaves the RI unused while you're billed On-Demand.
Interview Questions
Frequently Asked Questions
Summary
Instance type names encode family, generation, capability, and size in a fixed pattern; match the family to the workload's actual bottleneck (CPU, memory, storage, or GPU); and layer purchasing options — Savings Plans for steady-state, On-Demand for burst, Spot for interruption-tolerant work — to cut compute cost without changing architecture.