All Products
Search
Document Center

Elastic Compute Service:Hibernate an instance

Last Updated:Mar 11, 2024

If you do not need to run an Elastic Compute Service (ECS) instance or perform operations such as configuration upgrades or downgrades on the instance but want to retain the instance, we recommend that you hibernate the instance. A hibernated instance is different from a stopped instance. When you start a hibernated instance, the instance restores its applications to the state before hibernation and quickly resumes running.

Background information

  • When you hibernate an instance, the operating system of the instance saves data from the memory to the system disk. The saved data includes the applications that run in the operating system and the usage status of the applications. When you start a hibernated instance, the operating system reads the saved data from the system disk and restores the applications to the state before hibernation, and the instance quickly resumes running. In comparison, when you start a stopped instance, the operating system of the instance restarts the backend services and applications.

  • If an instance fails to be hibernated, the instance is automatically shut down. Data in the memory is not saved to the system disk. When the instance is started again, the operating system of the instance restarts the backend services and applications. The operating system cannot restore the applications to the state before the instance is shut down.

Warning

Hibernating instances may interrupt services. We recommend that you hibernate instances during off-peak hours.

The impact on billing for hibernated instances varies based on the billing method.

  • Subscription instance: If you hibernate a subscription instance, the expiration time and billing of the instance are not affected.

  • Pay-as-you-go instance: The billing of a pay-as-you-go instance is affected if you select No Fees for Hibernated Instances when you hibernate the instance. If you do not select the option when you hibernate the instance, the billing of the instance is not affected. The following table describes the billing details of resources for a hibernated pay-as-you-go instance.

Table 1. Billing of resources for a hibernated pay-as-you-go instance

Resource

No Fees for Hibernated Instances

Retain Instance and Continue Charging After Instance Is Hibernated

Computing resources (vCPUs and memory)

Released, and billing stops.

Retained, and billing continues.

Disks (system disk and data disk)

Retained, and billing continues.

Retained, and billing continues.

Internal IP address

Retained and free of charge.

Retained and free of charge.

Auto-assigned public IP address

Released. When the instance is started, a new public IP address is assigned to the instance free of charge.

Retained and free of charge.

EIP

Retained, and billing continues.

Retained, and billing continues.

Bandwidth

Billing continues.

Billing continues.

Limits

  • The hibernation feature is available only in the US (Silicon Valley) and Germany (Frankfurt) regions.

  • Before you can hibernate an instance, the instance must meet the following requirements:

    • The hibernation feature is enabled when the instance is created.

      Note

      The hibernation feature cannot be disabled after it is enabled. If you do not enable the hibernation feature when you create an instance, you cannot hibernate the instance.

    • The hibernation agent is installed on the instance.

  • You can enable the hibernation feature only when you create an instance by using an encrypted custom image. The following image versions are supported:

    • Windows Server 2016 or later

    • Ubuntu 18 or later

    • CentOS 7 or later

  • If the hibernation feature is enabled for an instance when the instance is created, you cannot perform the following operations on the instance:

    • Create custom images from the instance.

    • Create snapshots for disks.

    • Change the instance type.

    • Replace the operating system or system disk.

  • If the instance is a preemptible instance and you enable the hibernation feature for the instance, you can select only No Fees for Hibernated Instances when you hibernate the instance.

  • You cannot hibernate instances in scaling groups.

Step 1: Enable the hibernation feature when you create an instance

Enable the hibernation feature when you create an instance. Otherwise, you cannot hibernate the instance. When you create the instance, you must use an encrypted image.

  1. Obtain an encrypted custom image.

    You can use one of the following methods to obtain an encrypted custom image:

    • Prepare an encrypted custom image that meets the hibernation requirements.

    • Copy a custom image to create an encrypted image copy. For more information, see Copy a custom image.

    Note

    For information about the limits on images, see the Limits section of this topic.

  2. Create an ECS instance and enable the instance hibernation feature when you create the instance.

    For information about how to create an ECS instance, see Create an instance by using the wizard. Take note of the parameters that are described in the following table.

    Section

    Description

    Example

    Instance Type

    • Instance Type: Select an I/O optimized instance type that is not an ECS Bare Metal Instance type.

    • Memory:

      • Windows: Make sure that the selected instance type has less than 16 GiB of memory.

      • Linux: Make sure that the selected instance type has less than 150 GiB of memory.

    ecs.g6e.large

    Image

    • Select the encrypted custom image that you obtained in Step 1.

    • Select Instance Hibernation to enable the hibernation feature.

    • encrypted.windows2016

    • Select Instance Hibernation.

    Storage:

    • System Disk: required. The system disk must meet the following requirements:

      • Category: The system disk must be an ultra disk, standard SSD, or enhanced SSD (ESSD).

      • Capacity: When the hibernation feature is enabled, we recommend that you set the system disk capacity to at least twice the memory size. This way, the system disk can provide sufficient space to store memory data and allow the normal running of operating system and applications.

      • Disk Encryption: Select Disk Encryption and then select the key that is used to encrypt the custom image.

    • Data Disk: optional. To create data disks for an instance when you create the instance, you must select disk categories and specify the sizes and quantity of the disks. You must also determine whether to encrypt the disks.

    • System Disk: Select Enhanced SSD (ESSD), set the capacity to 60 GiB, select Disk Encryption, and then select Default Service CMK from the drop-down list.

    • Data Disk: Select Enhanced SSD (ESSD), set the capacity to 40 GiB, and do not select Disk Encryption.

    Network Type:

    Select a virtual private cloud (VPC).

    Note

    ECS instances in the classic network do not support the hibernation feature.

    [Default]vpc-bp1opxu1zkhn00g****

Step 2: Install the hibernation agent

After you enable the hibernation feature, you must install the hibernation agent on the instance before you can hibernate the instance.

  1. Use Cloud Assistant Agent to install the hibernation agent on a single instance.

    For more information, see Use the immediate execution feature.

    • Windows instance:

      acs-plugin-manager.exe --exec --plugin ecs-hibernate-win --params "install"
    • Linux instance:

      acs-plugin-manager --exec --plugin ecs-hibernate-linux --params "install"

      If the hibernation agent is installed, the following information is displayed on the execution details page.

      image.png

  2. Restart the instance for the hibernation agent to take effect.

    For more information, see Restart instances.

Step 3: Hibernate the instance

After the hibernation feature is enabled for the instance and the hibernation agent is installed on the instance, you can hibernate the instance in the Running state. You are unable to connect to the instance when the instance is hibernated.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the instance that you want to hibernate and choose More > Actions > Instance Status in the Stop column.

  5. In the Stop Instance dialog box, configure the parameters.

    1. Set Stopped By to Hibernate.

    2. Set Stop Mode to Retain Instance and Continue Charging After Instance Is Hibernated or No Fees for Hibernated Instances based on the billing method of the instance.

      • You are charged for subscription instances regardless of whether the instances are hibernated. If the instance is a subscription instance, select Retain Instance and Continue Charging After Instance Is Hibernated.

      • If the instance is a pay-as-you-go instance, select Retain Instance and Continue Charging After Instance Is Hibernated or No Fees for Hibernated Instances based on your business requirements.

        Note
        • For more information about the difference between Retain Instance and Continue Charging After Instance Is Hibernated and No Fees for Hibernated Instances, see the Billing of resources on a hibernated pay-as-you-go instance table of this topic.

        • Preemptible instances support only No Fees for Hibernated Instances. If the instance is a preemptible instance, select No Fees for Hibernated Instances.

    3. Click OK.

      Note

      The instance is stopped and enters the Stopped state. You can start the hibernated instance. For more information, see Start an instance.

References

You can use CloudOps Orchestration Service with the No Fees for Hibernated Instances feature to automatically batch hibernate and restart a large number of instances at designated times and save money. For more information, see Start or shut down ECS instances at a scheduled time.