QA
Intermediate LevelCloud Computing (AWS/GCP/Azure)

How do EC2 Spot Fleets combine mixed instance types to minimize termination risks?

❓ Interview Prompt: Explain EC2 Spot Fleets, Instance Diversification strategies, Capacity Rebalance triggers, and allocation strategies.

Using a single EC2 instance type for Spot workloads creates vulnerability: if AWS reclaims that specific instance type in an Availability Zone, your entire workload goes down. EC2 Spot Fleets minimize termination risk using Instance Diversification.

Spot Fleet Allocation Strategies:

1
Lowest Price: Launches instances from the pools with the lowest current spot price.
2
Capacity Optimized: Launches instances from pools with the highest available spare capacity, drastically reducing Spot interruption rates!
3
Diversified Pool: Distributes spot instances across multiple instance families (e.g. 'c5.large', 'c6g.large', 'm5.large') and AZs.
4
Capacity Rebalance: Automatically launches a replacement Spot instance before an existing instance receives its 2-minute termination notice!

Code Implementation Example

hcl
# Spot Fleet with mixed instance types for capacity diversification
resource "aws_ec2_fleet" "spot_fleet" {
  target_capacity_specification {
    default_target_capacity_type = "spot"
    total_target_capacity        = 20
  }

  spot_options {
    allocation_strategy = "capacity-optimized" # Minimizes termination interruptions!
  }

  launch_template_config {
    launch_template_specification { launch_template_id = aws_launch_template.app.id, version = "$Default" }
    override { instance_type = "c5.large" }
    override { instance_type = "c6g.large" }
    override { instance_type = "m5.large" }
  }
}
💡Terraform EC2 Fleet requesting capacity-optimized Spot instances across mixed instance types.
🎯 Interview Key Takeaway

Spot Fleets diversify requests across multiple instance types and AZs, minimizing interruption risks for fault-tolerant workloads.

#Spot Fleet#EC2#Spot#Diversification#Intermediate
Back to all Cloud Computing (AWS/GCP/Azure) Questions→

More Cloud Computing (AWS/GCP/Azure) Interview Questions

Beginner LevelCloud Computing (AWS/GCP/Azure)

How does Serverless Architecture (AWS Lambda / GCP Cloud Run) handle Auto-Scaling and Cold Starts?

Beginner LevelCloud Computing (AWS/GCP/Azure)

What is the difference between IaaS, PaaS, and SaaS cloud service models?

Beginner LevelCloud Computing (AWS/GCP/Azure)

What is AWS EC2 and what are On-Demand, Reserved, and Spot Instance pricing models?