All Products
Search
Document Center

Platform For AI:Specify preemptible instances

Last Updated:Feb 19, 2025

Elastic Algorithm Service (EAS) offers both public and exclusive resource groups. To reduce costs when deploying a service to EAS using a public resource group, you can opt for preemptible instances. This topic guides you through the process of specifying preemptible instances for an EAS service.

Introduction to preemptible instances

A preemptible instance is a cost-effective computing resource that operates on a preemptive mode by allowing you to set a price ceiling. EAS enables the selection of preemptible instances during service deployment. For more information, see preemptible instance.

Advantages

  • Cost savings: Preemptible instances are priced lower than standard pay-as-you-go instances, with real-time price fluctuations based on market supply and demand, often resulting in significant discounts.

  • Price tiers: Preemptible instances come in two types: with and without a protection period. The pricing, from lowest to highest, is as follows: price without protection period < price with protection period < standard instance price.

Purchase and use

  • Purchase configuration: You can indicate the use of preemptible instances in the configuration file and set a bid ceiling. The system will automatically bid for resources based on this configuration when deploying an EAS service.

  • Conditions for successful resource acquisition: A successful bid requires an adequate supply of preemptible instances and a bid that meets or exceeds the current market price.

  • Resource release and reallocation: Preemptible instances may be revoked due to inventory or market price changes. EAS will reallocate the highest priority active resources as per the configuration file to maintain service continuity.

  • Instance usage order during deployment: You can specify multiple instance types, such as preemptible and standard instances, when creating or updating a service. The system will utilize these instances in the order outlined in the configuration. If bidding fails or inventory is insufficient for a particular type, the system will automatically switch to the next available type in the sequence. For more information, see multiple instance types.

Usage rules

  • Instances with protection period:

    • By default, a minimum 1-hour protection period is provided to ensure resource availability.

    • After the protection period, continued usage is possible if inventory is available and the bid is at or above the market price.

  • Instances without protection period:

    • There is no protection period. Continued usage is possible if inventory is available and the bid is at or above the market price.

  • Release conditions:

    • With protection period: After the protection period, the instance may be released if inventory is insufficient or the bid falls below the market price.

    • Without protection period: The instance may be released if inventory is insufficient or the bid falls below the market price.

Billing model

Preemptible instances are billed on a pay-as-you-go basis, with charges based on the real-time market price.

Prerequisites

To use preemptible instances via a local client, you must download and authenticate the EASCMD client tool. For detailed instructions, see download and authenticate the client.

Use preemptible instances when creating a service

Through the console

  1. Log in to the PAI console. Select the destination region at the top of the page, and on the right, choose the destination workspace. Then click Enter EAS.

  2. Click Deploy Service. In the Custom Model Deployment section, click Custom Deployment.

  3. On the Custom Deployment page, configure the key parameters. For additional parameter configurations, refer to Service Deployment: Console.image

    Parameter

    Description

    Resource Type

    Select Public Resource.

    Deployment Resource

    • Resource Specification: Select a resource specification that supports preemption.

      Note

      Currently, whether a resource specification supports preemption is determined by whether the Preemption switch can be turned on after selecting the resource specification.

    • Preemption: Turn on the Preemption switch to indicate the use of preemptible instances.

    • Bid: Set a bid to automatically preempt resources. 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 instance can be created.

    • Configure multiple instance types:

      You can click the Add button to configure multiple preemptible instances. Up to 10 resource types can be added. For the logic of multiple instance configurations, see Multiple Instance Type Selection.

      Note

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

    Preemption Retention Duration

    The following configuration methods are supported:

    • Set Instance Usage To 1 Hour: You can set a 1-hour protection period for preemptible instances. After the instance is successfully preempted, it can be used for at least 1 hour by default.

    • No Definite Protection Period: Indicates that the protection period is disabled.

  4. Click Deploy. Once the Service Status shows Running, the service has been successfully deployed.

Through the local client

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

  2. Create a JSON file named service.json in the directory where the client is located. The file should contain the following 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
        }
      }
    }

    For key parameter descriptions and other parameters, see Command Usage Instructions.

    Parameter

    Description

    instance

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

    instances

    One or more instance types that you can specify. If resources are insufficient for the first instance type, the system prepares resources for the next instance type.

    • type: The specified instance type.

    • spot_price_limit is an optional parameter:

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

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

    disable_spot_protection_period

    Valid values:

    • false (default value): Indicates that after a preemptible instance is successfully created, a 1-hour protection period is provided by default. During the protection period, even if the market price is higher than the bidding price, the instance cannot be released.

    • true: Indicates that the protection period is disabled. Instances without a protection period are always about 10% cheaper than those with a protection period.

  3. Open the client and execute the following command in the directory containing the JSON file to create the service. For more details on operations, refer to Command Usage Instructions.

    eascmdwin64.exe create <service.json>

    Replace <service.json> with your JSON file's name in the command.

Modify service configuration to use preemptible instances

Through the console

  1. Navigate to the Resource Configuration page.

    1. On the Model Online Service (EAS) page, click the desired service name.

    2. In the Overview tab, within the Resource Information section, click Change Configuration.

  2. In the Cost-effective Resource Configuration tab, set the Preemption Retention Duration, add the Preemption resource type, and click OK.

    Note

    We recommend selecting common instance types as well to ensure sufficient resources for service deployment.

    image

    For additional parameter configurations, refer to Through the Console.

Through the local client

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

  2. Create a JSON file named instances.json in the directory where the client is located. The file should contain the following 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 details on key parameters and other parameters, see Use preemptible instances when creating a service.

  3. Open the client and run the following command in the directory containing the JSON file to modify the service configuration for preemptible instances. For more details on operations, refer to Command Usage Instructions.

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

    In this command, replace <service_name> with the name of your EAS service and <instances.json> with the name of the JSON file you created.

References