This Guidance shows how to build an Amazon Elastic Compute Cloud (Amazon EC2) Spot placement score tracker to monitor unused Amazon EC2 Spot Instance capacity. Those who use Spot Instances often have questions about configuring workloads for optimal resilience and savings. Key questions include which instances to use, whether to diversify across instance types and Availability Zones (AZs), which Regions work best for particular configurations, and how time of day impacts capacity. Running cloud workloads cost-effectively on Spot Instances requires flexibility across these dimensions. This Guidance helps provide those answers by automatically tracking real-time capacity metrics across Regions, AZs, and instance types. The result is that you gain insights that can guide you on instance choice, workload placement, and diversity strategies that align with AWS best practices for fault-tolerant Spot Instance usage.

Please note: [Disclaimer]

Architecture Diagram

[Architecture diagram description]

Download the architecture diagram PDF 

Well-Architected Pillars

The AWS Well-Architected Framework helps you understand the pros and cons of the decisions you make when building systems in the cloud. The six pillars of the Framework allow you to learn architectural best practices for designing and operating reliable, secure, efficient, cost-effective, and sustainable systems. Using the AWS Well-Architected Tool, available at no charge in the AWS Management Console, you can review your workloads against these best practices by answering a set of questions for each pillar.

The architecture diagram above is an example of a Solution created with Well-Architected best practices in mind. To be fully Well-Architected, you should follow as many Well-Architected best practices as possible.

  • The Spot placement score is a valuable metric that indicates how likely a Spot Instance request will succeed in a particular AWS Region or Availability Zone. This Guidance uses several AWS services to enable automated tracking and visualization of the Spot placement score for improving workload optimization. CloudWatch stores the Spot placement score metrics while also providing monitoring capabilities and dashboards to analyze the historical data. Amazon S3 hosts the dashboard configuration files in a durable and scalable storage layer. And the Lambda functions automate key steps through responsive serverless processing. Together, these services enhance operational excellence by boosting efficiency, reliability, and responsiveness within dynamic Spot-based workloads.

    Read the Operational Excellence whitepaper 
  • AWS Identity and Access Management (IAM) is used to control and manage access to AWS services and resources, limiting access to only authorized users. IAM roles and policies are scoped down to the minimum permissions required. The Lambda function is also configured to run with least privilege access, meaning it has only the permissions necessary to perform its tasks, reducing the risk of unauthorized access to other resources.

    Read the Security whitepaper 
  • Amazon EC2 Spot placement scores provide personalized recommendations on the optimal AWS Region or Availability Zone based on reliability requirements and real-time Spot capacity. This is made possible through a number of AWS Services with capabilities for computing, storing, and monitoring the metrics for Spot Instances. For example, Lambda is a service that enables the consistent, scheduled collection of Spot placement scores every 5 minutes. This serverless service scales automatically as needed.

    Also, Amazon S3 is a service that provides durable and fault-tolerant storage for both the Spot placement score metrics and the dashboard configuration data.

    Lastly, CloudWatch is a service that monitors this solution end-to-end, sending you alerts for quick issue detection.

    Read the Reliability whitepaper 
  • The EventBridge event bus invokes the Lambda function on a scheduled basis to collect Amazon EC2 Spot placement scores, which provide optimized recommendations for Spot Instance requests. EventBridge seamlessly connects the data flows between services, while Lambda minimizes manual tasks to boost efficiency.

    CloudWatch aids optimization through surveillance, allowing you to visualize performance over time. This serverless automation provides consistent metrics to inform ideal workload placement, while the monitoring capability allows for ongoing refinement of resource utilization.

    By leveraging these capabilities, the Spot placement score feature ensures Spot Instance resources are fully utilized and cost savings are achieved through proper capacity planning.

    Read the Performance Efficiency whitepaper 
  • The recommended services demonstrated throughout this Guidance provide cost-effective solutions tailored to meet the diverse needs of your workloads. For example, Amazon S3 provides cost-efficient storage for metrics and dashboards, enabling pay-as-you-go data access to inform analysis and planning. Lambda allows for automation costs to align with workloads through utilization-based billing. CloudWatch eliminates unnecessary expenditures by storing only essential infrastructure metrics. And finally, Amazon EC2 Spot placement scoring optimizes instance deployment, reducing spending by up to 90 percent.

    Read the Cost Optimization whitepaper 
  • Less computing overall lowers your carbon footprints organization-wide by maximizing resource utility. Here, Amazon S3 has the capability to store data in tiers to help optimize resource utilization, while the serverless compute capability of Lambda aligns usage with your workload needs. These services minimize waste and promote high infrastructure utilization, which are critical for sustainable workloads.

    Read the Sustainability whitepaper 

Implementation Resources

A detailed guide is provided to experiment and use within your AWS account. Each stage of building the Guidance, including deployment, usage, and cleanup, is examined to prepare it for deployment.

The sample code is a starting point. It is industry validated, prescriptive but not definitive, and a peek under the hood to help you begin.

AWS Compute
Blog

Optimizing Amazon EC2 Spot Instances with Spot Placement Scores

This blog post demonstrates how to use Spot placement scores to reduce interruptions, acquire greater capacity, and identify optimal configurations, times, and locations to run workloads on Spot Instances.

Disclaimer

The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.

References to third-party services or organizations in this Guidance do not imply an endorsement, sponsorship, or affiliation between Amazon or AWS and the third party. Guidance from AWS is a technical starting point, and you can customize your integration with third-party services when you deploy the architecture.

Was this page helpful?