Beginner LevelCloud Computing (AWS/GCP/Azure)
What is AWS EC2 and what are On-Demand, Reserved, and Spot Instance pricing models?
❓ Interview Prompt: Explain Amazon EC2 instance families (t4g, c6g, m6g, r6g) and purchasing options (On-Demand, Savings Plans/Reserved, Spot Instances).
Amazon Elastic Compute Cloud (EC2) provides resizable virtual compute servers (instances) in the cloud.
EC2 Instance Families:
•
General Purpose ('m' / 't' series): Balanced compute, memory, and networking (e.g. 'm6g.large').
•
Compute Optimized ('c' series): High performance CPU processors for batch processing and media encoding (e.g. 'c6g.xlarge').
•
Memory Optimized ('r' series): High RAM for in-memory caches (Redis) and relational databases (e.g. 'r6g.2xlarge').
Pricing Models:
1
On-Demand: Pay per second without commitment. Flexible, highest cost per hour.
2
Reserved Instances / Savings Plans: 1-year or 3-year commitment offering up to 72% discount for predictable steady-state workloads.
3
Spot Instances: Bid on spare AWS compute capacity for up to 90% discount. Can be reclaimed by AWS with a 2-minute notice! Ideal for fault-tolerant batch processing.
Code Implementation Example
hcl
# Terraform resource creating EC2 instance with Spot purchasing option
resource "aws_instance" "app_worker" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t4g.micro"
instance_market_options {
market_type = "spot"
spot_options {
max_price = "0.010" # Max spot price per hour
}
}
}💡Terraform configuration requesting an AWS EC2 Spot instance.
🎯 Interview Key Takeaway
Use On-Demand for unpredictable workloads, Savings Plans for steady baseline servers, and Spot for fault-tolerant batch tasks.
#EC2#Spot Instances#Cost Optimization#AWS#Beginner
Back to all Cloud Computing (AWS/GCP/Azure) Questions→