All Products
Search
Document Center

Platform For AI:Scheduled scaling

Last Updated:Jun 04, 2024

You can configure scheduled resource scaling in Platform for AI (PAI) to handle scenarios in which workloads can be estimated to prevent resource waste. After you enable this feature, Elastic Algorithm Service (EAS) can automatically increase the number of service instances to a specified value before peak business hours. After the peak hours end, EAS automatically reduces the number of service instances to a specified value at a specific point in time. This topic describes how to configure the scheduled scaling feature. This topic also describes the compatibility between the scheduled scaling and auto scaling features.

Background information

You can configure scheduled scaling by using one of the following methods: Method 1: Configure scheduled scaling in the PAI console and Method 2: Configure scheduled scaling by using a client. If you enable both scheduled scaling and auto scaling for a service, the minimum and maximum numbers of instances for auto scaling change based on the expected number of instances for scheduled scaling. For more information, see Compatibility between scheduled scaling and auto scaling.

Method 1: Configure scheduled scaling in the PAI console

Enable scheduled scaling

  1. Go to the EAS-Online Model Services page.

    1. Log on to the PAI console.

    2. In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace that you want to manage.

    3. In the left-side navigation pane, choose Model Deployment > Elastic Algorithm Service (EAS). The Elastic Algorithm Service (EAS) page appears.

  2. On the Elastic Algorithm Service (EAS) page, click the name of the service that you want to manage to go to the Service Details page.

  3. Click the Auto Scaling tab. In the CronHPA section, click Enable Scheduled Scaling.

  4. In the CronHPA Settings dialog box, configure the required parameters. You can also click Add to configure multiple scheduled scaling tasks. The following table describes the parameters. After you configure the parameters, click OK.

    Parameter

    Description

    Task Name

    The name of the scheduled scaling task. Follow the on-screen instructions to configure this parameter.

    Expected Instances

    The expected number of instances.

    Scaling Schedule

    You can use one of the following methods to configure a schedule to trigger the scheduled scaling task:

    • Week: You can trigger the task at a specific time every week.

    • Day: You can trigger the task at a specific time every day.

    • Cron Expression: You can enter a cron expression to trigger the task. For information about cron expressions, see Appendix: Cron expressions.

Update the configurations of a scheduled scaling task

  1. In the CronHPA section of the Auto Scaling tab, click Manage CronHPA.

  2. In the CronHPA Settings dialog box, modify the values of the Task Name, Expected Instances, and Scaling Schedule parameters based on your business requirements.

  3. Click Update.

Disable scheduled scaling

  1. In the CronHPA section of the Auto Scaling tab, click Disable Scheduled Scaling.

  2. In the confirmation dialog box, click OK.

Method 2: Configure scheduled scaling by using a client

Enable scheduled scaling or update the scheduled scaling configurations

By default, the scheduled scaling feature is disabled after you create a service. You can log on to the EASCMD client and run the cronscale subcommand to enable this feature or update related configurations. For information about how to log on to the EASCMD client, see Download the EASCMD client and complete user authentication.

Command syntax (Windows 64 is used as an example)

eascmdwin64.exe cronscale [region]/[service_name] -s cronscale.json

Before you run the command, you need to configure the cronscale.json file based on the parameter descriptions in the following table. The following code provides a sample content of the cronscale.json file:

{
  "ExcludeDates": ["* * * * * 6,0"],
  "ScaleJobs": [
    {
      "Schedule": "0 15,45 * * * *",
      "TargetSize": 6
    },
    {
      "Schedule": "0 0,30 * * * *",
      "TargetSize": 1
    },
    {
      "Schedule": "0 7,22,37,52 * * * *",
      "TargetSize": 3
    }
  ]
}

Parameter

Description

Example

ExcludeDates

The time that you want to exclude when you schedule a scaling task. Specify the time by using a cron expression. For more information, see Appendix: Cron expressions.

Note

If the time specified by the ExcludeDates parameter is also included in the ScaleJobs parameter, the scheduled scaling task is not executed.

["* * * * * 0,6"]

The scheduled scaling task is not executed on Saturdays or Sundays.

ScaleJobs

The configurations of the scheduled scaling task that you want to execute. The ScaleJobs parameter includes the Schedule, TargetSize, and Name options.

  • Schedule: the time at which you want to execute the task. Specify the time by using a cron expression. For more information, see Appendix: Cron expressions.

  • TargetSize: the expected number of instances.

  • Name: the custom name used to identify the task. This option is optional.

    Take note of the following rules when you configure the Name option:

    • The name can contain only letters and digits.

    • The name cannot exceed 20 characters in length.

[ { "Schedule": "0 0 18 * * *", "TargetSize": 10, "Name": "scale-up" }, { "Schedule": "0 0 22 * * *", "TargetSize": 3, "Name": "scale-down" }]

The number of service instances is increased to 10 at 18:00 and reduced to 3 at 22:00 every day.

View the scheduled scaling configurations of a service

Command syntax (Windows 64 is used as an example)

eascmdwin64.exe cronscale show [region]/[service_name]
[RequestId]: F4C38D2D-4B38-5CB7-B706-9A1C41D4617E
+--------------+----------------------------+---------+------------+----------------------+
|     NAME     |          SCHEDULE          |  STATE  | TARGETSIZE |    LASTPROBETIME     |
+--------------+----------------------------+---------+------------+----------------------+
| scale-jobs-1 | 0 5,15,25,35,45,55 * * * * | Succeed |          1 | 2022-03-03T13:45:00Z |
| scale-jobs-0 | 0 0,10,20,30,40,50 * * * * | Succeed |          4 | 2022-03-03T13:50:00Z |
+--------------+----------------------------+---------+------------+----------------------+

Disable scheduled scaling

Command syntax (Windows 64 is used as an example)

eascmdwin64.exe cronscale rm [region]/[service_name]

Compatibility between scheduled scaling and auto scaling

You can enable both scheduled scaling and auto scaling features. If you enable both features, the value of the min or max parameter specified for auto scaling is changed to the value of the TargetSize parameter that you specified for scheduled scaling.

Important

The scheduled scaling configurations overwrite the auto scaling configurations. However, the auto scaling configurations remain effective until the scheduled time. Each time the service is updated or upgraded, the original auto scaling configurations are used.

The following table describes the values of the min and max parameters before and after both features are enabled.

Values of the min and max parameters for auto scaling

Scheduled scaling

Actual values of the min and max parameters

Description

2/5

1

1/5

If the expected number of instances specified for scheduled scaling is smaller than the minimum number of instances specified for auto scaling, the minimum number of instances specified for auto scaling is changed to the expected number of instances specified for scheduled scaling.

2/5

6

6/6

If the expected number of instances specified for scheduled scaling is greater than the maximum number of instances specified for auto scaling, the minimum and maximum numbers of instances specified for auto scaling are changed to the expected number of instances specified for scheduled scaling. In this case, the values of the min and max parameters are the same and auto scaling is not performed.

2/5

3

3/5

If the expected number of instances specified for scheduled scaling is between the minimum and maximum numbers of instances specified for auto scaling, the minimum number of instances specified for auto scaling is changed to the expected number of instances specified for scheduled scaling.

Appendix: Cron expressions

You can use cron expressions to enable scheduled scaling.

Cron expressionsCron表达式

  • Special characters

    • Asterisk (*)

      You can use an asterisk (*) to represent all valid values. For example, the following cron expression represents 00:00 on the first day of each month: 0 0 0 1 * *.

    • Hyphen (-)

      You can use a hyphen (-) to represent a range of valid values. For example, the following cron expression represents 12:00, 13:00, and 14:00 of each day: 0 0 12-14 * * *.

    • Comma (,)

      You can use a comma (,) to represent a range of valid values. For example, the following cron expression represents 12:00 and 14:00 of each day: 0 0 12,14 * * *.

    • Forward slash (/)

      You can use a forward slash (/) to specify an interval. For example, the following cron expression represents the zeroth, fifteenth, thirtieth, and forty-fifth minutes of each hour: 0 */15 * * * *. You can use a forward slash (/) together with a hyphen (-) to specify an interval in a specific value range. For example, the following cron expression represents the fifth, twentieth, and thirty-fifth minutes in the range of fifth to fortieth minutes of every hour: 0 5-40/15 * * * *.

  • Description of time-related parameters

    Name

    Valid value

    Valid special character

    Second

    0-59

    * / , -

    Minute

    0-59

    * / , -

    Hour

    0-23

    * / , -

    Day

    1-31

    * / , -

    Month

    1-12 or JAN-DEC

    * / , -

    Day of Week

    0-6 or SUN-SAT

    * / , -

References

  • If you enable auto scaling, the system automatically scales instances based on the specified metrics. For more information, see Auto scaling.

  • The elastic resource pool feature of EAS allows you to scale out a service that is deployed in a dedicated resource group even if the node resources of the resource group are insufficient. For more information, see Elastic resource pool.