Preemptible instances may be interrupted and reclaimed at any time due to pricing or inventory factors. We recommend that you use external storage, such as File Storage NAS and Object Storage Service (OSS), to store data for preemptible instances. If a preemptible instance stores important data or configurations, you can retain the data or configurations by using one of the following methods: Enable the economical mode for the instance, configure the system disk and data disks attached to the instance to not be released together with the instance, and create snapshots or custom images from the instance.
Data retention and restoration methods
Method 1: Enable the economical mode for a preemptible instance
When you create a preemptible instance, set the Instance Interruption Mode parameter to Stop in Economical Mode. After the interruption and reclamation of the preemptible instance are triggered, the system stops the instance in economical mode. You can restart the instance to restore the instance data. Before you use this method, take note of the following items:
You can configure the Instance Interruption Mode parameter only when you create the preemptible instance. After the preemptible instance is created, you cannot modify the parameter.
After the preemptible instance is stopped in economical mode, the instance may fail to restart due to pricing or inventory factors.
After the preemptible instance starts from the economical mode, the static public IP address of the instance may change.
The instance may fail to restart from the economical mode due to pricing or inventory factors. If you want to immediately restore the instance data, you can restore the data from a snapshot or a custom image.
Method 2: Configure the system disk and data disks attached to a preemptible instance to not be released together with the instance
Before a preemptible instance is interrupted and reclaimed, configure the system disk and data disks attached to the instance to not be released together with the instance. After the instance is interrupted and reclaimed, attach the system disk and data disks of the instance to a different instance to restore data. Before you use this method, take note of the following items:
The system disk is retained and can be attached to a different instance only as a data disk.
The disks and the instance to which you want to attach the disks must reside in the same zone.
Method 3: Create snapshots or custom images from a preemptible instance
You can create snapshots or custom images from a preemptible instance after the instance is created. After the instance is interrupted and reclaimed, you can create a new instance by using a custom image to restore data. Before you use this method, take note of the following items:
You can use only system disk snapshots to create custom images. You cannot use data disk snapshots to create custom images.
The new instance that you create must reside in the same region as the custom image that you use to create the instance. To create a new instance in a different region, you must copy the custom image to the destination region. For more information, see Copy a custom image.
Procedure for data retention and restoration
Enable the economical mode for a preemptible instance
Flowchart
Retain data
Procedure
Log on to the ECS console, go to the instance buy page, and then click the Custom Launch tab.
Follow the on-screen instructions to configure the instance parameters based on your business requirements. Take note of the following parameters. For information about other parameters, see Create an instance on the Custom Launch tab.
Billing Method: Select Preemptible Instance.
Instance Interruption Mode: Select Stop in Economical Mode.
NoteAfter a preemptible instance is stopped in economical mode, the computing resources (vCPUs, GPUs, and memory), static public IP address, and public bandwidth associated with the static public IP address of the instance are reclaimed and no longer billed. The billing for other resources of the preemptible instance continues, such as the cloud disks (system disk and data disks), elastic IP addresses (if any), and snapshots.
If you call the RunInstances operation to create preemptible instances, set the
SpotInterruptionBehavior
parameter to Stop to enable the economical mode for the instances.
Restore data
Procedure
After you receive an interruption and reclamation notification for a preemptible instance, the instance is stopped in economical mode in 5 minutes. You can view the status of the preemptible instance on the ECS console - Instance page.
After the preemptible instance is stopped in economical mode, start the instance when the market price does not exceed the bid price and the inventory is sufficient. You can also call the StartInstance or StartInstances operation to start the instance.
NoteTo query the market price, go to the instance buy page, select the instance type of the preemptible instance, and then view the price history of the instance type. You can also call the DescribeSpotPriceHistory operation to view the price history of the instance type.
To query the inventory, go to the instance buy page and select the preemptible instance type. If you can create a new preemptible instance, the instance type is in stock. You can also call the DescribeAvailableResource operation to query the inventory.
Configure the system disk and data disks attached to a preemptible instance to not be released together with the instance
Flowchart
Retain data
Procedure
When you create a preemptible instance, configure the system disk or data disks to not be released together with the instance. Perform the following steps:
Log on to the ECS console, go to the instance buy page, and then click the Custom Launch tab.
Follow the on-screen instructions to configure the instance parameters based on your business requirements. Take note of the following parameters. For information about other parameters, see Create an instance on the Custom Launch tab.
Set the Billing Method parameter to Preemptible Instance.
In the Storage section, clear the Release with Instance option for the system disk or data disks.
If you do not clear the Release with Instance option for the system disk or data disks when you create the instance, you can change the disk release mode on the Instance Details or Block Storage page.
If you call the RunInstances operation to create preemptible instances, set the DeleteWithInstance
parameter to false to prevent the system disk or data disks from being released together with the instance. You can also call the ModifyDiskAttribute operation and set the DeleteWithInstance
parameter to false.
Restore data
Considerations
The disks that you want to attach to a new instance are in the Unattached (Available) state.
The instance to which you want to attach the disks is in the Running (Running) or Stopped (Stopped) state and not in the Locked (Locked) state.
Procedure
You can call the AttachDisk operation to attach a disk to an instance.
Create snapshots or custom images from a preemptible instance
Flowchart
Retain data
Procedure
This section describes how to create a snapshot for a cloud disk on the Instance page in the ECS console. You can also create a snapshot for a cloud disk on the Snapshots or Block Storage page.
Go to the ECS console - Instance page.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
Click the ID of the instance from which you want to create a snapshot. On the instance details page, click All Actions in the upper-right corner. In the pane that appears, search for and click Create Snapshot.
In the Create Snapshot dialog box, configure the snapshot parameters and click OK.
Parameter
Description
Resource Type
The default selection is Cloud Disk, which allows you to create a snapshot for a single disk.
NoteYou can also select Instance to select one or more disks from the instance, create a snapshot-consistent group, and then create snapshots for multiple disks in the group to ensure data consistency across multiple disks. For more information, see Create a snapshot-consistent group.
Disk
Select the disk for which you want to create a snapshot. You can select a system disk or a data disk.
Snapshot Name
Specify a name for the snapshot.
Retention Period
Set the retention period for the snapshot. You can choose to retain it permanently or specify a custom number of days.
Permanently: After the maximum number of snapshots is reached, new snapshots cannot be created.
Custom retention period: The snapshot will be automatically deleted by the system after the retention period expires.
NoteFor the upper limit of manually created snapshots, see Snapshot overview.
If you choose a custom retention period, when the retention period is 3 days away from expiration, the Retention Period column in the snapshot list will highlight Released After Xx Days. You can extend the retention period before the snapshot expires as needed. For more information, see Extend the retention period of a snapshot.
Regardless of whether the retention period is permanent or custom, if you no longer need the snapshot, it is recommended to delete it promptly to avoid incurring ongoing snapshot fees. For more information, see Delete a snapshot.
Advanced Settings
Instant Access
ESSD series disks (ESSDs, ESSD AutoPL disks, ESSD Entry disks, and Regional ESSDs) have the instant access feature enabled by default. Other categories of disks do not have this feature enabled by default.
NoteThe instant access feature allows snapshots to be available within seconds after creation, without waiting for the snapshot to be uploaded to OSS. You can use the snapshot immediately for operations such as rolling back disks, creating new disks, or sharing snapshots. For more information, see Use the instant access feature.
Tag
Set the tag key-value pairs for the snapshot. You can use the tag feature to manage resources in a unified manner.
Resource Group
Set the resource group to which the snapshot belongs. You can use resource groups to manage snapshots at different levels.
(Optional) View the creation progress of the snapshot on the Disk Snapshots tab.
In the Progress column, view the upload progress of the snapshot to OSS. When you move your pointer over Progress of Upload to OSS: xx%, the system displays the estimated remaining time for the upload.
NoteThe estimated remaining time to upload a snapshot to OSS dynamically varies based on multiple factors. For more information, see the Considerations section of the "Create a snapshot" topic.
You can call the DeleteSnapshot operation to cancel an ongoing snapshot creation task.
If Progress of Upload to OSS: 100% is displayed, the snapshot is uploaded to OSS. The disk data is backed up.
Click the ID of the preemptible instance to go to the instance details page. In the upper-right corner of the page, click All Actions. In the pane that appears, search for and click Create Custom Image.
In the Create Custom Image dialog box, configure the parameters and click OK.
The time required to create an image varies based on the disk size. You must wait until the snapshot of each disk is created before you can use the image.
You can also create a snapshot by calling the CreateSnapshot operation and create a custom image by calling the CreateImage operation.
Restore data
Procedure
Go to the ECS console - Images page.
In the top navigation bar, select the region and resource group of the resource that you want to manage.
Find the image that you want to use and click Create Instance in the Actions column.
On the Custom Launch tab, click the Custom Images tab in the Image section. Verify that the custom image created from the preemptible instance in the previous step is selected. For information about other parameters, see Create an instance on the Custom Launch tab.
You can also call the RunInstances operation with the ImageId
parameter specified to create an instance from a custom image.