Demand for Spot instances can vary significantly from moment to moment, and the availability
of Spot instances can also vary significantly depending on how many unused EC2 instances
are available. In addition, no matter how high you bid, it is still possible that your
Spot instance will be interrupted. Therefore, you must ensure that your application is
prepared for a Spot instance interruption. We strongly recommend that you do not use
Spot instances for applications that can't be interrupted.
The following are the possible reasons that Amazon EC2 will terminate your Spot
Spot Instance Termination
The best way to protect against Spot instance interruption is to architect your
application to be fault tolerant. In addition, you can take advantage of
Spot instance termination notices, which provide a
two-minute warning before Amazon EC2 must terminate your Spot instance.
This warning is made available to the applications on your Spot instance using an
item in the instance metadata. For example, you can check for this warning in the
instance metadata periodically (we recommend every 5 seconds) using the following
if curl -s http://169.254.169.254/latest/meta-data/spot/termination-time | grep -q .*T.*Z; then echo terminated; fi
For information about other ways to retrieve instance metadata, see Retrieving Instance Metadata.
If your Spot instance is marked for termination by Amazon EC2, the
termination-time item is present and it specifies the approximate
time in UTC when the instance will receive the shutdown signal. For example:
If Amazon EC2 is not preparing to terminate the instance, or if you
terminated the Spot instance yourself, the
termination-time item is
either not present (so you receive an HTTP 404 error) or contains a value that is
not a time value.
Note that while we make every effort to provide this warning the moment that your
Spot instance is marked for termination by Amazon EC2, it is possible that
your Spot instance will be terminated before Amazon EC2 can make the warning available.
Therefore, you must ensure that your application is prepared to handle an unexpected
Spot instance interruption even if you are checking for Spot instance termination
If Amazon EC2 fails to terminate the instance, the Spot bid status is set to
termination-time remains in the instance metadata with the original
approximate time, which is now in the past.