EC2 Spot instance Maximum runtime - amazon-web-services

I read myself pretty much through all the online docs of EC2.
Still one question is unanswered to me:
What is the maximum runtime of a spot instance (uninterrupted) ?
everything is well documented for < 6h runtime. But what happens afterwards ? is the instance automatically terminated or does is keep running until the ressources are no more available ? somehow i didn`t find anything clear on this.
Thanks !

As mentioned in the AWS documentation under How Spot Instances Work:
Spot Instances run until you terminate them or until Amazon EC2 must interrupt them (known as a Spot Instance interruption).
Therfore in theory an EC2 spot instance will run indefinitely until you terminate it or AWS interrupts it because your spot bid price is too low, or similar.

Spot instances will not terminate until you do or it is interrupted from AWS side (Eg. The Spot price is greater than your maximum price). So your application should be able to handle these terminations gracefully.
More details : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html
Also if you terminate it you will be charge for that hour. If AWS terminates it you are not charged for that hour.

Related

Hibernating EC2 spot instances. When is it possible, when is it not?

I'm confused about when you can or cannot hibernate spot instances.
(1.) Under "Hibernation prerequisites," the documentation says that hibernation "is available for On-Demand Instances and Reserved Instances. It is not available for Spot Instances. For more information, see Hibernating interrupted Spot Instances." https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html#hibernating-prerequisites
(2.) But the following article: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html#hibernate-spot-instances
... says that you can set instances to automatically hibernate upon interruption.
What explains this apparent contradiction?
My guess would be that you cannot manually initiate hibernation from a spot instance, but you can configure a spot to hibernate automatically upon interruption. Is that right?
You cannot manually hibernate a Spot Instance.
However, a Spot Instance can be hibernated automatically if the Spot Instance is interrupted and hibernation has been configured.
See: Preparing for instance hibernation
I think it is supported, but with some exceptions. I suspect this sentence is missing the word all:
It is not available for all Spot Instances.
The page that is linked to in the next sentence, Hibernating interrupted Spot Instances, describes the requirements imposed on spot instances.

EC2 spawning from nowhere, no autoscaling group found

I'm having an issue with AWS boxes (EC2) where I terminate the box and it re-spawns. To give context, there is no autoscaling group. Anywhere I can search for some config that might be triggering the launch?
I would make sure you don't have a persistent spot request active in your account, and also check to see if you perhaps installed the AWS Instance scheduler - either or both of those could be starting instances on your behalf - (double check the autoscaling group, that is the most obvious reason though)
If you terminate a running Spot Instance that was launched by a
persistent Spot request, the Spot request returns to the open state so
that a new Spot Instance can be launched. To cancel a persistent Spot
request and terminate its Spot Instances, you must cancel the Spot
request first and then terminate the Spot Instances. Otherwise, the
persistent Spot request can launch a new instance.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html#terminating-a-spot-instance
https://aws.amazon.com/solutions/instance-scheduler/
So I found out the culprit, maybe it can help more people. Apparently, there is a service from AWS called OpsWorks that automates things like Cheff of Puppet, which my company had configured some time ago. That would be checking for instances running and triggering re-provisioning when it didn't see the instance running. OpsWorks is here

EC2 Spot Instance capacity pool

I understand that spot instances are terminated if the bid price is exceeded, and that they can't launch if there is no capacity to do so or the instance limit is reached. I've not seen them terminated due to over-subscription before. Used AWS CLI:
aws ec2 request-spot-instances --spot-price "0.8" --instance-count 1 --type "one-time" --launch-specification c:\path\to\spot-instance-spec.json
The r4.4xlarge linux spot launched successfully in (my) eu-west-1b, then terminated and the status in the spot request is:
instance-terminated-capacity-oversubscribed: Your Spot instance was terminated as there is no more unused capacity available in this pool.
Does anyone know what this means specifically? Is a pool just the AZ? Is it down to more expensive spots? Is it due to on-demands being launched?
The AWS documentation now has a definition of Spot instance pool:
Spot Instance pool – A set of unused EC2 instances with the same instance type, operating system, Availability Zone, and network platform.
Source: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html
Your Spot Instances continue to run as long as your maximum price is
at or above the Spot price, there is available capacity for your
instance type, and you don't terminate the instance. If a change in
the Spot price or available capacity requires Amazon EC2 to terminate
your Spot Instances, the Spot request goes into a terminal state. For
example, if your price equals the Spot price but Spot Instances are
not available, the status code is
instance-terminated-capacity-oversubscribed. A request also goes into
the terminal state if you cancel the Spot request or terminate the
Spot Instances.
Its mentioned here in AWS Doc, and also check for limitation of spot request.For some instance there is a limit beyond that it cant be launched.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html

Amazon Instance Got Terminated frequently

We have basic plan Amazon configuration. Also we have created Windows instance which is terminated frequently and new Ip address is assigned. I don't know how to check and why its terminated frequently.
Under standard conditions, Amazon EC2 instances are never terminated on their own. You may be accidentally using EC2 Spot instances which works on a bidding model. AWS has the power to terminate these instances with a warning time of ~2 minutes if there is a a higher bid for the spot instance.
If your instances get terminated immediately after you launch, refer this page: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_InstanceStraightToTerminated.html
For more information on EC2 spot instances, refer this page:
http://aws.amazon.com/ec2/purchasing-options/spot-instances/

Does ELB connection draining apply when spot instances are terminated?

A new AWS ELB feature, connection draining, was recently announced.
http://aws.amazon.com/about-aws/whats-new/2014/03/20/elastic-load-balancing-supports-connection-draining/
Apparently this works with Auto Scaling Groups - instances are drained before being removed, but does that also apply to spot instances that are being terminated by AWS due to a rising spot price?
Nothing definitive I could find, but from my reading on this, I think the answer is almost definitely no. Spot instances are different animals than regular instances, and the way the connection draining works you can specify upto 60 minute delay before your connection-drained enabled instance gets terminated when it becomes unhealthy - if AWS was to allow this added layer of safety to spot instances, it would completely up-end the way spot instances are used and how they are positioned.
The trade-off for using spot instances has always been, "you can pay a fraction of the cost, but you risk being terminated at any instant without warning"...if they added an up to 60 minute 'warning' to spot instances, while it would be fantastic from the end-users point of view, I think it would severely eat into AWS's on-demand and reserved instance pricing model and thus they probably won't support this anytime soon (unless forced to by competitive pressure).
EDIT 1/6/2015: now, almost a year later, AWS has indeed added a 'two minute warning' for EC2 spot instance termination. https://aws.amazon.com/blogs/aws/new-ec2-spot-instance-termination-notices/