All Products
Search
Document Center

Platform For AI:Specify preemptible instances

Last Updated:Feb 28, 2025

Elastic Algorithm Service (EAS) provides public resource groups and exclusive resource groups. When you use a public resource group to deploy a service to EAS, you can specify preemptible instances for the service to reduce costs. This topic describes how to specify preemptible instances for an EAS service.

Introduction to preemptible instances

Preemptible instances are a type of instances that you can use to deploy services in preemptible mode with a bid price, providing cost-effective computing resources. EAS allows you to select preemptible instances to deploy services. For more information, see Overview.

Benefits

  • Cost saving: The biggest advantage of preemptible instances is their low cost. Prices fluctuate in real time based on the market demand and supply. Preemptible instances are typically more cost-effective than common pay-as-you-go instances in public resource groups.

  • Tiered pricing: Preemptible instances are categorized into two types: instances with a protection period and instances without a protection period. The prices of the instances are sorted in ascending order: price of a preemptible instance without a protection period < price of a preemptible instance with a protection period < price of a common instance

Purchase and usage

  • Purchase configuration: You can specify whether to use preemptible instances in the configuration file and set the bid price. When you deploy an EAS service, the system automatically bids for preemptible resources to create preemptible instances based on the configuration file.

  • Conditions for creating preemptible instances: If the resource inventory is sufficient and the bid price of an instance type is higher than the market price, a preemptible instance can be created.

  • Instance releasing and resource reallocation: Preemptible instances may be released due to insufficient inventory or market price changes. In this case, EAS reallocates available resources with the highest priority based on the configuration file to ensure service continuity.

  • Order in which multiple instance types are used to create an instance for service deployment: When you create or update a service, you can specify multiple instance types, such as preemptible instance types and common instance types. When you deploy a service, the system uses the instance types to create an instance based on the configuration order. If an instance type fails to create an instance or the resource inventory is insufficient for instance creation, the system automatically uses the next available instance type to create an instance based on the configuration order.

Usage notes

  • Instances with a protection period:

    • By default, an instance can be used for one hour in which the resources are available.

    • After the protection period ends, if the resource inventory is sufficient and the bid price for an instance of a specific instance type is higher than the market price, the instance can be used continuously.

  • Instances without a protection period:

    • If the resource inventory is sufficient and the bid price for an instance of a specific instance type is higher than the market price, the instance can be used continuously.

  • Releasing conditions:

    • Instances with a protection period: After the protection period ends, if the resource inventory is insufficient or the bid price for an instance of a specific instance type is lower than the market price, the instance may be released.

    • Instances without a protection period: If the resource inventory is insufficient or the bid price for an instance of a specific instance type is lower than the market price, the instance may be released.

Billing

Preemptible instances are billed based on the pay-as-you-go billing method. You are charged based on the market price.

Prerequisites

If you use a client to specify preemptible instances, make sure that the EASCMD client is installed and identity authentication is complete. For more information, see Download the EASCMD client and complete identity authentication.

Specify preemptible instances when you create a service

Use the console to specify preemptible instances

  1. Log on to the PAI console. Select a region and a workspace. Then, click Enter Elastic Algorithm Service (EAS).

  2. Click Deploy Service and select Custom Deployment in the Custom Model Deployment section.

  3. On the Custom Deployment page, configure the parameters described in the following table. For information about other parameters, see Deploy a model service in the PAI console.image

    Parameter

    Description

    Resource Type

    Select Public Resources.

    Deployment Resources

    • Resource Type: Select an instance type that supports bidding.

      Note

      To check whether an instance type supports the bidding feature, you can turn on Bidding to check whether the bidding feature can be enabled after you select the instance type.

    • Bidding: If you turn on Bidding, you can use preemptible instances.

    • Bid Price: Specify a bidding price to bid for preemptible instances. If the resources required to create a preemptible instance are sufficient and the bidding price that you specify is greater than or equal to the market price of the instance, you can use the instance.

    • Specify multiple instance types:

      You can click Add to add multiple instance types. You can add up to 10 instance types. For more information about how to specify multiple instance types, see Specify multiple instance types.

      Note

      We recommend that you select common instance types at the same time to ensure that resources are sufficient for service deployment.

    Preemptible Instance Protection Period

    The following configuration methods are supported:

    • 1-Hour Protection Period: You can specify a 1-hour protection period for a preemptible instance. During the protection period, the system ensures your access to the instance.

    • No Fixed Protection Period: The preemptible instance does not have a protection period.

  4. Click Deploy. When the value of the Service Status parameter changes to Running, the service is deployed.

Use a client to specify preemptible instances

  1. Download the EASCMD client and complete identity authentication. In this example, Windows 64 is used.

  2. Create a service configuration file named service.json in the directory in which the client is located. Sample content:

    {
      "name": "service_example",
      "model_path": "http://examplebucket.aliyuncs.com/models%2Fmnist_saved_model.tar.gz",
      "processor": "tensorflow_cpu_1.12",
      "metadata": {
        "instance": 1,
      }
      "cloud": {
        "computing": {
          "instances": [
            {"type": "ecs.g7.2xlarge", "spot_price_limit": 2.00},
            {"type": "ecs.g7.4xlarge", "spot_price_limit": 4.00},
            {"type": "ecs.g7.2xlarge"},
            {"type": "ecs.g7.4xlarge"}
          ],
          "disable_spot_protection_period": true
        }
      }
    }

    The following table describes the parameters that are required in the service configuration file. For information about other parameters, see Run commands to use the EASCMD client.

    Parameter

    Description

    instance

    The number of service instances. In this example, one instance is specified in the JSON configuration file.

    instances

    The instance types. You can specify one or more instance types. If resources are insufficient for the first instance type, the system prepares resources for the next instance type.

    • type: the instance type.

    • spot_price_limit: the highest bidding price for preemptible instances. This parameter is optional.

      • If you configure this parameter, preemptible instances whose prices are less than the value specified by this parameter are used. Unit: USD. The pay-as-you-go billing method is supported.

      • If you do not configure this parameter, standard pay-as-you-go instances are used.

    disable_spot_protection_period

    Specifies whether to disable the instance protection period. Default value: false. Valid values:

    • false: The preemptible instance has a 1-hour protection period after the instance is created. During the protection period, the instance provides services even if the market price is higher than the bidding price.

    • true: The preemptible instance does not have a protection period. Instances without a protection period are 10% cheaper than instances that have a protection period.

  3. Run the following command in the directory in which the JSON file is located to create the service. For more information, see Run commands to use the EASCMD client.

    eascmdwin64.exe create <service.json>

    Replace <service.json> with the name of the JSON file that you created.

Specify preemptible instances when you modify the settings of a service

Use the console to modify service settings and specify preemptible instances

  1. Go to the Resource Configuration page.

    1. On the Elastic Algorithm Service (EAS) page, click the name of the service that you want to modify.

    2. On the Overview tab of the service details page, click Modify Configuration in the Resource Information section.

  2. In the Resource Configuration panel, set the Resource Configuration Mode parameter to Cost-effective Resource Configuration, configure the Spot Instance Protection Period parameter, specify preemptible instance types, and then click OK.

    Note

    We recommend that you select common instance types at the same time to ensure that resources are sufficient for service deployment.

    image

    For information about other parameters, see Use the console to specify preemptible instances.

Use a client to modify service settings and specify preemptible instances

  1. Download the EASCMD client and complete identity authentication. In this example, Windows 64 is used.

  2. Create a file named instances.json in the directory in which the client is located. Sample content:

    {
      "cloud": {
        "computing": {
          "instances": [
            {"type": "ecs.g7.2xlarge", "spot_price_limit": 2.00},
            {"type": "ecs.g7.4xlarge", "spot_price_limit": 4.00},
            {"type": "ecs.g7.2xlarge"},
            {"type": "ecs.g7.4xlarge"}
          ],
          "disable_spot_protection_period": true
        }
      }
    }

    For information about the parameters, see Specify preemptible instances when you create a service.

  3. Run the following command in the directory in which the JSON file is located to modify the service settings and specify preemptible instances: For more information, see Run commands to use the EASCMD client.

    eascmdwin64.exe modify <service_name> -s <instances.json>

    Replace <service_name> with the name of the EAS service and <instances.json> with the name of the JSON file that you created.

References