Launching EC2 Instances: All Available Methods
In this lesson, we explore the different ways to launch EC2 instances in AWS. Each method has its own advantages based on cost savings, flexibility, and guaranteed availability. Below is a structured breakdown of the key topics covered.
1. Spot Instances
Spot instances allow you to bid for unused EC2 capacity at significantly lower prices (up to 70% savings compared to On-Demand).
Checking Spot Pricing History
- Navigate to Spot Requests on the AWS Management Console.
- View the price history for different instance types (e.g.,
c3.large, c4.large).
- Prices vary across Availability Zones (AZs) but generally remain stable.
- The On-Demand price is represented by a black bar for comparison.
Requesting a Spot Instance
- Click on Request Spot Instances.
- Use Launch Templates or configure manually.
- Specify:
- AMI (Amazon Linux 2)
- Key Pair
- Instance parameters (e.g., CPU, memory)
- Set Request Details:
- Maximum price per instance
- Validity period (start and end time)
- Termination policy when the request expires
- Load balancing settings (target group or classic ELB)
- Target Capacity:
- Define instance count (e.g., 10 instances).
- Or, define based on vCPUs or memory.
- Choose interruption behavior:
- Enable rebalancing if needed.
- Networking Settings:
- Choose a VPC and Availability Zones.
- Instance Selection:
- Manually select instance types (e.g.,
c3.large, c4.large).
- OR define minimum/maximum vCPUs, memory, and other attributes.
- AWS will match available instances accordingly.
- Allocation Strategy:
- Capacity-Optimized (ensures availability)
- Lowest Price (maximizes cost savings)
- Diverse Pool (balances multiple instance types)
Finally, AWS provides a cost estimate showing the savings compared to On-Demand pricing.