By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Does an EC2 gracefully shut down when I terminate it?

0

I have an EC2 instance that runs a spring boot java application as a service, meaning the service will automatically start up after the EC2 rebooted and will also automatically shut down when the stop action is called on the EC2 instance. But what happens when I terminate the EC2 instance? Will the java application running on the instance be allowed to gracefully shut down before the EC2 instance is terminated or are all process halted abruptly on termination?

I would also like to know how long a stopping EC2 instance will wait for a service to gracefully shut down and if there is a way to configure this waiting time.

Thanks

asked 2 years ago1.6K views
1 Answer
0

According to the docs:

When an EC2 instance is terminated using the terminate-instances command, the following is
registered at the OS level:

* The API request will send a button press event to the guest.
* Various system services will be stopped as a result of the button press event. systemd handles a graceful shutdown of the system. Graceful shutdown is triggered by the ACPI shutdown button press event from the hypervisor.
* ACPI shutdown will be initiated.
* The instance will shut down when the graceful shutdown process exits. There is no configurable OS shutdown time.
profile pictureAWS
EXPERT
answered 2 years ago
  • what is ment by 'guest'? Furthermore you say that there is no configurable shutdown time. Does that mean that the termination process will hang indefinately if the systemd process does not shutdown properly and hangs?

  • Hi Viridios, According to Amazon User Guide for Linux Instances, if the instance OS does not shut down cleanly within a few minutes, a hard shutdown is performed. Even so, If the instance remains in the shutting-down state for several hours, Amazon EC2 treats it as a stuck instance and forcibly terminates it.

  • The guest is your instance, from the hypervisor point of view.

  • The guest is your instance, from the hypervisor point of view.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions