Q
Problem solve Get help with specific problems with your technologies, process and projects.

Avoid data loss during AWS Spot Instance termination

While Spot Instances can be economical, they can also cause data loss without proper backup. Use databases to save instance data, and set up interruption notices to be warned.

AWS provides spare compute capacity with its EC2 Spot Instances. Whether you handle high-performance computing...

workloads, run a stateless web server or transcode video, these instance types could be the most economical way to use compute power.

But, while Spot Instances cost up to 90% less than their On-Demand counterparts, they only run as long as your bid price is above the current Spot Instance price. It's important to prepare for potential AWS Spot Instance termination, especially when you have data on the instances that you don't want to lose. Take these measures to prevent data loss.

Hold on to your data

First, store your Spot Instance data in a database, such as Amazon Relational Database Service or Amazon DynamoDB -- or you can even use Amazon S3. When you store data, you prevent unnecessary losses in the event of AWS Spot Instance termination, and you can simply provision new ones and continue where you left off.

Alternatively, you could opt to preserve the entire disk. By default, AWS deletes all Amazon Elastic Block Store (EBS) volumes when Spot Instances are terminated. To keep your disk, uncheck Delete for EBS volumes when you create a Spot Instance request in AWS Management Console.

Opt to keep your EBS volume after AWS Spot Instance termination.
Deselect the delete option to preserve your EBS volume.

Beat the buzzer

AWS also provides Spot Instance interruption notices, which can help prevent data loss. When your bid price becomes lower than the current price, AWS' Spot Instance termination process begins, but it doesn't happen immediately. Instead, AWS sends you a two-minute warning, which gives you time to offload your data and complete other preparations, such as detaching your instances from a load balancer.

There are multiple ways to detect whether your instances are about to terminate. For example, the instance metadata updates with the exact time of the shutdown:

curl http://169.254.169.254/latest/meta-data/spot/termination-time

You can also use DescribeSpotInstanceRequests, rather than poll from the instance itself.

Additionally, AWS added Spot Instance interruption notices to Amazon CloudWatch Events in January 2018. This lets you prepare for AWS Spot Instance termination via Lambda or Simple Notification Service topics, which can help automate the data backup process. AWS has also upgraded Spot Instances with other features, like streamlined access to capacity, instance hibernation and an option to purchase without placing a bid, which help make them a worthwhile option for budget-conscious users.

This was last published in May 2018

Dig Deeper on Amazon EC2 (Elastic Compute Cloud) management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

Which of your workloads is a good match for EC2 Spot Instances?
Cancel

-ADS BY GOOGLE

SearchCloudApplications

TheServerSide.com

SearchSoftwareQuality

SearchCloudComputing

Close