User guide
Tutorial: Amazon EC2 Spot Instances
Overview
Spot Instances enable you to bid on unused Amazon EC2 capacity and run any instances that you acquire
for as long as your bid exceeds the current Spot Price. Amazon EC2 changes the Spot Price periodically
based on supply and demand, and customers whose bids meet or exceed it gain access to the available
Spot Instances. Like On-Demand Instances and Reserved Instances, Spot Instances provide another
option for obtaining more compute capacity.
Spot Instances can significantly lower your Amazon EC2 costs for applications such as batch processing,
scientific research, image processing, video encoding, data and web crawling, financial analysis, and
testing. Additionally, Spot Instances are an excellent option when you need large amounts of computing
capacity but the need for that capacity is not urgent.
To use Spot Instances, place a Spot Instance request specifying the maximum price you are willing to
pay per instance hour; this is your bid. If your bid exceeds the current Spot Price, your request is fulfilled
and your instances will run until either you choose to terminate them or the Spot Price increases above
your bid (whichever is sooner).You can terminate a Spot Instance programmatically as shown this tutorial
or by using the AWS Management Console or by using the AWS Toolkit for Visual Studio.
It's important to note two points:
1. You will often pay less per hour than your bid. Amazon EC2 adjusts the Spot Price periodically as
requests come in and available supply changes. Everyone pays the same Spot Price for that period
regardless of whether their bid was higher. Therefore, you might pay less than your bid, but you will
never pay more than your bid.
2. If you're running Spot Instances and your bid no longer meets or exceeds the current Spot Price, your
instances will be terminated. This means that you will want to make sure that your workloads and
applications are flexible enough to take advantage of this opportunistic—but potentially
transient—capacity.
Spot Instances perform exactly like other Amazon EC2 instances while running, and like other Amazon
EC2 instances, Spot Instances can be terminated when you no longer need them. If you terminate your
instance, you pay for any partial hour used (as you would for On-Demand or Reserved Instances).
However, if your instance is terminated by Amazon EC2 because the Spot Price goes above your bid,
you will not be charged for any partial hour of usage.
This tutorial provides an overview of how to use the .NET programming environment to do the following.
• Submit a Spot Request
• Determine when the Spot Request becomes fulfilled
• Cancel the Spot Request
• Terminate associated instances
Prerequisites
This tutorial assumes that you have signed up for AWS, set up your .NET development environment, and
installed the AWS SDK for .NET. If you use the Microsoft Visual Studio development environment, we
recommend that you also install the AWS Toolkit for Visual Studio. For instructions on setting up your
environment, see Getting Started (p. 3).
Version v2.0.0
80
AWS SDK for .NET Developer Guide
Tutorial: Amazon EC2 Spot Instances