New – EC2 Spot Instance Termination Notifications

New – EC2 Spot Instance Termination NotificationsMore Info

When prospective AWS users inquire about how it stands apart from conventional on-premises infrastructure, I often highlight the advantages of EC2 Spot Instances and the EC2 Spot Market. The ability to place bids on idle EC2 instances at a price of your choosing tends to captivate their interest, prompting them to consider how they might leverage this distinctive, powerful, and cost-effective feature in their applications.

Before we delve deeper, let’s revisit the lifecycle of a Spot Instance:

  1. You (or an application acting on your behalf) submit a bid to operate a specified number of EC2 instances of a chosen type, including a price you are willing to pay per hour.
  2. Your instances are launched when your bid surpasses the current Spot price, which fluctuates based on supply and demand.
  3. If the Spot price exceeds your bid, AWS reclaims the Spot instance to allocate it to another customer.

Introduction of Spot Instance Termination Notices

Today, we are enhancing the reclamation process by introducing a two-minute warning, formally known as a Spot Instance Termination Notice. This notice allows your application to utilize this time to save its state, upload final log files, or detach from an Elastic Load Balancer. This adjustment enables a wider range of applications to exploit the scalability and affordability of Spot Instances.

The Termination Notice can be accessed by code running on the instance via the instance’s metadata at http://169.254.169.254/latest/meta-data/spot/termination-time. This field becomes available once the instance is marked for termination and indicates the time when a shutdown signal will be dispatched to the operating system. At this point, the Spot Instance Request’s bid status will be updated to marked-for-termination. This bid status can be retrieved through the DescribeSpotInstanceRequests API, facilitating management of Spot bids and instances.

We suggest that relevant applications check for the termination notice at five-second intervals. This gives the application nearly two full minutes to prepare for the impending termination. Here’s a timeline to clarify the termination process (the “+” signifies time relative to the start of the timeline):

  • +00:00 – Your Spot instance is marked for termination as the current Spot price has risen above your bid price. The status of your Spot Instance Request is updated to marked-for-termination, and the /spot/termination-time metadata is set to a time exactly two minutes ahead.
  • +00:00 to +00:05 – Your instance (assuming it polls every five seconds) becomes aware that it is scheduled for termination.
  • +00:05 to +02:00 – Your application can now make all necessary arrangements for shutdown, such as checkpointing ongoing work, uploading final log files, and detaching from an Elastic Load Balancer.
  • +02:00 – The operating system receives the shutdown command, and the bid status updates to instance-terminated-by-price. Make sure to consult the documentation on Tracking Spot Requests with Bid Status Codes before relying on this field’s values in your code.

Spot Instances in Practice

Numerous AWS customers are effectively utilizing Spot Instances, and I encourage you to do the same! For instance:

Last November, AWS Partner Cycle Computing reported that they employed Spot Instances to establish a 70,000 core compute environment across three AWS Regions for a total cost of $5,594. This cluster facilitated one million simulations for a new head design for a Western Digital hard drive.

Additionally, AWS customer Novartis utilized 10,600 Spot Instances (approximately 87,000 cores) to execute 39 years of computational chemistry in just 9 hours at a cost of $4,232, screening 10 million compounds against a common cancer target.

Furthermore, Honda Motors achieved a 70% reduction in costs by combining Spot and On-Demand Instances relative to a previous setup that relied solely on On-Demand Instances. To learn more about this and other high-performance computing use cases, you can watch the Finding High Performance in the Cloud for HPC panel session from AWS re:Invent.

Now Available

This feature is available for use now! There are no charges for the HTTP requests made to retrieve instance metadata or for calls to the DescribeSpotInstanceRequests API. For more insights, check out another blog post here.

— Laura

For more authoritative insights on this topic, visit this link. If you’re curious about the initial experience as an Amazon warehouse worker, this Quora resource is an excellent place to start.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *