4

Is there a maximum shutdown for instances in Amazon EC2? And is that maximum configurable via the EC2-API?

We transfer data at shutdown time from the instance to S3. This works great for small files. But if they get bigger (several GB) we experience that not all data is transferred.

OS: Ubuntu 11.04 (EBS-Backed AMI)

2
  • You don't say what. OS your instance is running.
    – user9517
    Jul 28, 2011 at 14:31
  • Also, is it instance-backed or EBS backed? Jul 28, 2011 at 14:35

5 Answers 5

7

When you stop or terminate an EC2 instance, Amazon sends a soft shutdown request to the operating system to let it wrap up in a clean, safe manner. If the system does not indicate it is powering down within a short time (minutes) then Amazon effectively pulls the power plug forcing a hard shutdown.

I am not aware of any commitment from Amazon about how long this soft shutdown grace period is, so I would recommend you not assume or rely on having a specific minimum. Even if Amazon gives you 10 minutes today for one instance, they could easily reduce this to 3 minutes tomorrow when, say, they have a large demand for new instances.

If you need to do important wrap up before an instance shuts down, then send the instance a signal (web request or ssh command), wait for it to complete its task, then initiate the EC2 shutdown.

If you are using, say, spot instances where the instance can be shut down at any point by Amazon, then save your work frequently so that not much of it will be lost if the instance gets terminated suddenly.

1
  • 1
    Another option in a more sophisticated infrastructure is to set your EBS-backed instances to not delete the volume, and have a reaper application that looks for leftover volumes to clean them up by saving the important data (to S3, RDB, etc) and deleting the volume.
    – Skaperen
    Aug 21, 2012 at 17:05
2

The maximum shutdown time we experienced is around 10 minutes. After that time the machine will be killed by Amazon.

Everything else would be surprising since Amazon bills only the time a instance was running and not the time it is shutting down; so they would loose money if the shutdown takes longer and longer.

2
  • 2
    I would not depend on it always being 10 minutes. It might vary by instance type, too, either now or in the future. I suggest what Eric Hammond said, and have a script you run to do a more graceful shutdown by signaling your app to stop and saving the data. Then it would do the system halt.
    – Skaperen
    Aug 21, 2012 at 17:03
  • I'm almost waiting 25 minutes now. It's a M3 Medium Ec2 instance with Ubuntu 14.04 Nov 14, 2014 at 13:14
2

https://docs.aws.amazon.com/cli/latest/reference/ec2/reboot-instances.html

If an instance does not cleanly shut down within four minutes, Amazon EC2 performs a hard reboot.

1

I've been dealing with a similar request recently.

The truth is, there is no timeout figure given as stated in AWS CLI ec2 stop-instances doc.

When you stop an instance, we attempt to shut it down forcibly after a short while.

https://docs.aws.amazon.com/cli/latest/reference/ec2/stop-instances.html


You should shutdown your instance in a low level way. Eg. via sshing to the instance and calling shutdown, poweroff, etc. directly.

0

I had an instance in shutdown for over 30 minutes as I expected it to timeout and be hard shutdown at some point. I clicked on the Instance Actions drop down and selected "Stop" again and was instead given the option to force stop the instance. Once clicking yes to force the stop it took about 5 minutes for my instance to enter the stopped state. It would seem this is not automatic anymore.

1
  • Not only can an OS get "stuck", but sometimes Xen can get stuck, too. I would imagine if an iSCSI session gets hung, it might be a while to time out, or require a hard shutdown of the Dom0 or the hardware to clear it any faster.
    – Skaperen
    Aug 21, 2012 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .