Table of contents
1.
Introduction
2.
Amazon EC2 Spot Fleet
2.1.
Spot Fleet Configuration Strategies
2.2.
Working with Spot Fleets
2.3.
CloudWatch Metrics for Spot Fleet
2.4.
Automatic Scaling for Spot Fleet
2.5.
Including On-Demand Instances
2.6.
Spot Fleet Recommendations
3.
Amazon EC2 Fleet
3.1.
Example Configurations for EC2 Fleet and Spot Fleet
3.2.
Monitoring Fleet Events using Amazon EventBridge
3.3.
Fleet Quotas
4.
Benefits of AWS Spot Fleet
5.
Frequently Asked Questions
5.1.
How is Spot Fleet different from individual Spot Instance requests?
5.2.
What types of instances can I include in an AWS Spot Fleet?
5.3.
How do I configure an AWS Spot Fleet request?
5.4.
What happens if the Spot capacity is unavailable for my requested instance types?
5.5.
Can I use Auto Scaling with AWS Spot Fleet?
6.
Conclusion
Last Updated: Mar 27, 2024
Medium

AWS Spot Fleet

Author Juhi Pathak
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Amazon Web Services (AWS) provides two powerful tools for managing fleets of instances in the cloud: Amazon EC2 Spot Fleet and EC2 (Elastic Compute Cloud) Fleet. These services offer cost-effective options for launching instances across multiple Availability Zones, utilizing various instance purchasing options like On-Demand Instances, Reserved Instances, and Spot Instances.

AWS Spot Fleet

In this article, we'll delve into the key features and use cases of both Spot Fleet and EC2 Fleet, as well as explore some best practices for their configuration.

Amazon EC2 Spot Fleet

Amazon EC2 Spot Fleet

A Spot Fleet is a collection of Spot Instances and optionally On-Demand Instances, launched based on user-defined criteria. Spot Fleet automatically selects Spot capacity pools that match your specified requirements and launches Spot Instances to achieve the target capacity set for the fleet. By default, Spot Fleets maintain the target capacity by launching replacement instances when Spot Instances are terminated. However, users can also submit Spot Fleet as a one-time request, which doesn't persist after instances are terminated.

Spot Fleet Configuration Strategies

When creating a Spot Fleet request, users have two main configuration options. They can choose between two request types:
 

"Request" type: In this setting, Spot Fleet places an asynchronous one-time request for the desired capacity. If the capacity diminishes due to Spot interruptions, the fleet does not attempt to replenish Spot Instances or submit requests in alternative Spot capacity pools.
 

"Maintain" type: With this configuration, Spot Fleet places an asynchronous request for the desired capacity and maintains it by automatically replenishing any interrupted Spot Instances. Users can specify the request type during the Spot Fleet creation process in the Amazon EC2 console.

Working with Spot Fleets

Spot Fleets offer a flexible and cost-effective solution for managing instances, especially for fault-tolerant applications and workloads that can withstand pauses. Users can leverage Spot Fleets for various use cases, such as batch processing, data analysis, CI/CD workloads, and more.

CloudWatch Metrics for Spot Fleet

AWS provides CloudWatch metrics to monitor the performance of Spot Fleets, enabling users to gain insights into fleet capacity, instance health, and termination rates. Spot Fleets are collections of Spot Instances, which are spare EC2 instances available at significantly reduced prices compared to On-Demand instances. These metrics play a vital role in optimizing and fine-tuning the fleet's configuration. For example- Suppose you have a web application hosted on a Spot Fleet that consists of 50 Spot Instances. To monitor the fleet's performance, you use CloudWatch metrics. After a certain period, you observe the following metrics:

Fleet Request Capacity: 50, Fulfilled Capacity: 45, Pending Capacity: 2, Terminating Capacity: 3, Target Capacity: 50, Instance Health: Healthy: 42, Unhealthy: 3, Unknown: 5, Spot Fleet Request Duration: 120 seconds

Automatic Scaling for Spot Fleet

To further optimize resource utilization, we combine Spot Fleets with Auto Scaling groups to adjust the fleet's capacity based on demand fluctuations. When Spot Fleets are combined with Auto Scaling groups, the fleet's capacity can automatically adjust in response to fluctuations in demand. This is achieved by setting up scaling policies that define how the fleet's size should change based on CloudWatch metrics or custom alarms. For example- users can create scaling policies that increase the fleet's capacity when CPU utilization is high and decrease it when the CPU utilization is low.

Including On-Demand Instances

Spot Fleet requests can include On-Demand Instance requests offering a blend of Spot and On-Demand capacity to meet varying workload demands. By including On-Demand Instances in the Spot Fleet request, users can create a balanced fleet that combines the cost advantages of Spot Instances with the reliability of On-Demand Instances. This approach is especially useful for applications that require a certain level of guaranteed capacity and cannot solely rely on Spot Instances due to their potential for interruptions.

Spot Fleet Recommendations

Amazon suggests using Auto Scaling groups or EC2 Fleets instead of Spot Fleet for a fleet that includes Spot Instances, as the RequestSpotFleet API (on which Spot Fleet is based) is considered a legacy API with no planned investments.

Amazon EC2 Fleet

Similar to Spot Fleet, EC2 Fleet allows users to launch a fleet of instances in a single API call. The key difference is that EC2 Fleet provides more resilience by supporting On-Demand Instances, Reserved Instances, and Spot Instances together across various instance types and Availability Zones.

Example Configurations for EC2 Fleet and Spot Fleet

Users can define a wide range of configurations for both EC2 Fleet and Spot Fleet, tailoring the fleet to specific performance requirements and cost considerations. AWS offers example configurations to guide users in creating optimal fleets for their workloads.

Monitoring Fleet Events using Amazon EventBridge

Amazon EventBridge provides a way to monitor and respond to fleet events. It enables users to automate actions based on specific events, like instance launches or terminations.

Fleet Quotas

AWS imposes quotas on the number of instances users can launch in a fleet. It's crucial to understand and monitor these quotas to avoid disruptions in instance launches.

Benefits of AWS Spot Fleet

Spot Fleet provides the following advantages:
 

  • Simplified fleet management through a single API call.
     
  • Support for launching diverse instance types, allowing optimization for different workloads.
     
  • Greater control over instance distribution across Availability Zones.


Amazon EC2 Spot Fleet and EC2 Fleet are powerful tools that enable users to manage fleets of instances. They provide an efficient way to optimize costs. By understanding the distinct features of both services, users can make informed decisions. They can deploy workloads that best suit their needs. Leveraging the allocation strategies can further enhance the performance of AWS instance fleets.

Frequently Asked Questions

How is Spot Fleet different from individual Spot Instance requests?

While Spot Instance requests are for a single instance, Spot Fleet is designed to manage a group of Spot Instances. It allows you to define a target capacity, and AWS will maintain it by replacing any terminated Spot Instances.

What types of instances can I include in an AWS Spot Fleet?

Spot Fleet supports both EC2 Spot Instances and On-Demand Instances. You can create a mix of Spot and On-Demand capacity to strike a balance between cost savings based on your needs.

How do I configure an AWS Spot Fleet request?

You can configure an AWS Spot Fleet request using the AWS Management Console, AWS CLI, or SDKs. You specify the target capacity, instance types, and other parameters to meet your application's needs.

What happens if the Spot capacity is unavailable for my requested instance types?

If the Spot capacity is unavailable for your requested instance types, Spot Fleet will try to fulfill the request using other available pools. You can specify fallback options to use On-Demand Instances if Spot capacity is unavailable.

Can I use Auto Scaling with AWS Spot Fleet?

Yes, AWS Spot Fleet can be integrated with Auto Scaling. There is an automatic adjustment of the fleet's capacity based on specified scaling policies. This enables seamless scaling up or down based on changes in demand. It helps maintain performance and cost efficiency.

Conclusion

This article discussed AWS Spot Fleet, an Amazon Web Services tool that offers cost-effective options for launching instances across multiple Availability Zones. Alright! So now that we have learned about AWS Panorama, you can refer to other similar articles.


You may refer to our Guided Path on Code Ninjas Studios for enhancing your skill set on DSACompetitive ProgrammingSystem Design, etc. Check out essential interview questions, practice our available mock tests, look at the interview bundle for interview preparations, and so much more!

Happy Learning!

Live masterclass