All Products
Search
Document Center

:Hibernate an ECS instance

Last Updated:Apr 02, 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 for a period of time, 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 the applications on the instance 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 state 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. 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 stopped. Data in the memory is not saved to the system disk. When the instance is restarted, 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 stopped.

Warning

When you hibernate instances, service interruptions may occur. We recommend that you hibernate instances during off-peak hours.

The billing of hibernated instances varies based on the billing methods of the instances.

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

  • Pay-as-you-go instance: 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 billing of a pay-as-you-go instance is affected. The following table describes the retention and billing details of resources for a hibernated pay-as-you-go instance.

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. Billing stops.

Retained. Billing continues.

Disks (system disk and data disks)

Retained. Billing continues.

Retained. 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.

Elastic IP address (EIP)

Retained. Billing continues.

Retained. 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 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 in this topic.

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

    For information about how to create an instance, see Create an instance on the Custom Launch tab. Take note of the parameters that are described in the following table.

    Parameter

    Description

    Example

    Instance

    • 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 ensure that the operating system and applications run as expected.

      • 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 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 Encryption.

    Network and Zone

    Select a virtual private cloud (VPC).

    Note

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

    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 Create and run a Cloud Assistant command.

    • 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 an instance.

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 when it is running. 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 icon1 > Instance Status > Stop in the Actions 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 for a hibernated pay-as-you-go instance table in 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. Then, 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

The Scheduled Startup/Shutdown feature of CloudOps Orchestration Service (OOS) allows you to batch manage the hibernation and startup times of a large number of instances. You can use this feature together with the economical mode feature to save costs. For more information, see Start or stop instances at a scheduled time.