Amazon EC2 Hibernation : How it works?

Amazon EC2 Hibernation

So far in our AWS posts we have learned if we stop the EC2 instance the data on the EBS volumes persists. If we start the EC2 instance, the data is restored on the EC2 instance. However if we terminate an EC2 instance, then by default the root device volume also gets terminated.

Advertisements

Now Amazon has introduced a new EC2 hibernation feature which when enabled on an EC2 instance signals the operating system to save the contents of your RAM to your Amazon EBS root volume.

Hibernation saves effort in setting up the environment or applications all over again, and saves time by reducing the long start up time taken by applications. Using hibernate, you can maintain a fleet of pre-warmed instances that can get to a productive state faster without modifying your existing applications.

When the EC2 instance is started again following things happen:

  • RAM contents are reloaded.
  • Processes that were stopped while stopping the EC2 instance will be resumed.
  • Contents of EBS volumes are loaded again.
  • Previously attached data volumes are reattached and the instance retains its instance ID.

In order to perform hibernation on the EC2 instance you need to have the hibernation enabled on the EC2 instance while configuring the details for the EC2 instance.

However in order for the EC2 instance to be enabled for hibernation you need to keep in mind the following pre-requisites for using the hibernation feature:

  • Hibernation is supported with following instance types:
    • C3, C4, C5, M3, M4, M5, R3, R4, R5, and T2.
  • Instance RAM size should be less than 150GB
  • AMIs supported: Amazon Linux 2 AMI, Amazon Linux AMI, Ubuntu 18.04 LTS, and Ubuntu 16.04 LTS.
  • EC2 instance must be backed by EBS volumes, instance stores aren’t supported.
  • EBS root volume size should be able to accommodate RAM contents along with other data from OS & applications.
  • EC2 instance root volumes must have encryption enabled to ensure the security of the content stored at EBS.
  • Hibernation isn’t supported on the Spot Instance Types, while it is supported on the On-Demand & Reserved Instance types.

Related – Elastic Compute Cloud in AWS : Amazon EC2

Limitations on the EC2 instances enabled for hibernation:

  • You cannot increase/decrease the size of hibernated instance.
  • Cannot enable snapshot or AMIs from instance in hibernation state.
  • If an EC2 instance is enabled for auto-scaling group or used by Amazon ECS, then you cannot hibernate that instance.
  • An EC2 instance cannot be kept hibernated for a period of more than 609 days. To keep the instance for longer than 60 days, you must start the hibernated instance, stop the instance, and start it.
  • To hibernate an instance that was launched using your own AMI, you must first configure your AMI to support hibernation.

Refer to below figure to understand how the hibernation works:

  • Once you initiate hibernation on EC2, it goes into stopping state. The contents from the RAM are moved to the EBS root volume, processes running are freeze and then are normal shutdown on the EC2 instance is performed.
  • Once the shutdown is complete the instance moved into the stopped state. While the instance is in stopped state the EBS volume remains attached to the EC2 along with the RAM contents stored on EC2.
  • Now when a hibernated instance is brought up, it boots up and the OS reads the contents of the RAM from EBS volume & it resumes the processes earlier frozen to their initial state.
  • The instance retains its private IPv4 addresses and any IPv6 addresses when hibernated and started. We release the public IPv4 address and assign a new one when you start it.
  • The instance retains its associated Elastic IP addresses.

A hibernated instance isn’t charged for when it is in stopped state, however the instance is charged for while it is in stopping state or while the contents are being migrated from the RAM to the EBS volumes.

Related – Hosting a Web Server on AWS EC2 Instance

Share this:
Advertisements

Tags:

Related Posts

About The Author

Add Comment

Social Media Auto Publish Powered By : XYZScripts.com
Select your currency
USD United States (US) dollar