All Products
Search
Document Center

Platform For AI:Create and use preemptible instances

Last Updated:Aug 09, 2024

Elastic Algorithm Service (EAS) provides public resource groups and dedicated 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.

Background information

  • Preemptible instances

    Preemptible instances cost less than standard instances. You can specify preemptible instances when you deploy a service to EAS to reduce costs. To specify preemptible instances, you need to offer your highest bidding price to compete for the instances. For more information about preemptible instances, see Overview.

    Preemptible instances are more cost-effective than pay-as-you-go instances of the public resource group. Prices of preemptible instances fluctuate in real time based on the changes in supply and demand. You can configure a protection period for preemptible instances. Instances with a protection period cost more than instances without a protection period. The following section shows the prices of instances in ascending order:

    preemptible instances without a protection period < preemptible instances with a protection period < standard instances

    .

    Note

    Preemptible instances may be released when the market price or stock changes. If a preemptible instance of a service is released, EAS scans the instance types configured for the service in the configuration file and selects the type with the highest priority to create another instance.

  • Method for creating preemptible instances

    When you deploy a service, you can specify whether to use preemptible instances for the service and specify the highest bidding price for preemptible instances in the service configuration file. Then, the system bids for preemptible instances based on the service configuration file.

    If you want to create preemptible instances, the following requirements must be met:

    • The resources required to create the preemptible instances are sufficient.

    • Your highest bidding price is greater than or equal to the market price of the preemptible instances.

  • Usage notes of preemptible instances

    • By default, a new preemptible instance provides service for at least 1 hour. This means that the instance has a 1-hour protection period, during which the system ensures your access to the instance.

    • After the 1-hour protection period ends, you can continue to use the instance if the resources required to create the instance are sufficient and your previous bidding price is greater than or equal to the market price of the instance.

      If the preceding requirements are not met, your instance may be released after the protection period ends.

  • Release preemptible instances

    • A preemptible instance is released when the 1-hour protection period ends and the resources required to create the instance are insufficient.

    • A preemptible instance is released when the 1-hour protection period ends and your previous bidding price is less than the market price of the instance.

    • A preemptible instance is released if the instance has no protection period and the resources required to create the instances are insufficient or your previous bidding price is lower than the market price of the instance.

  • Billing

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

  • Order in which preemptible instances are used

    When you create or update a service by using a service configuration file, you can specify multiple instance types in the file, including preemptible instances and standard instances. The system selects the first instance type to create or update the service. If your bidding price is less than the market price of the instance type or the resources required to create instances of the instance type are insufficient, the second instance type is used.

Prerequisite

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. Go to the Deploy Service page. For more information, see Deploy a model service in the PAI console.

  2. On the Deploy Service page, configure the following parameters. For more information about other parameters, see Deploy a model service in the PAI console. image

    Parameter

    Description

    Resource Group Type

    Select Public Resource Group.

    Resource Configuration Mode

    Select Cost-effective Resource Configuration.

    Preemptible Instance Protection Period

    Valid values:

    • 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 Protection Period: The preemptible instance does not have a protection period.

    Deployment

    • Resource Type: Select Spot.

    • Node Type: Select an appropriate node type.

    • Bid Price: Specify a bid price to bid for preemptible instances.

      If the resources required to create the instance are sufficient and your bidding price is greater than or equal to the market price of the instance, the instances can be created.

    • Specify multiple instance types:

      You can click the image..png icon to specify multiple preemptible instances. You can add up to five resource types. For more information about how to specify multiple instances, see Specify multiple instance types.

      Note

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

  3. Click Deploy. When Service Status 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 key parameters that are required in the file. For more 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: your highest bidding price for preemptible instances. This field is optional.

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

      • If you do not configure this field, 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 dialog box. For more information, see the "Modify in the console" section of the Specify multiple instance types topic.

  2. On the Cost-effective Resource Configuration tab, configure the Preemptible Instance Protection Period parameter, specify Preemptible instance types, and then click OK.

    Note

    We recommend that you also select common instances t the same time to ensure that resources are sufficient for service deployment.

    image

    For more information about how to configure 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 key parameters, see the "Specify preemptible instances when you create a service" section in this topic.

  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