Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring an Auto Scaling Rule

Updated on 2024-11-29 GMT+08:00

Function

This API is used to configure auto scaling rules.

The API used for cluster creation and job execution can also be used to create an auto scaling rule.

URI

  • Format

    POST /v1.1/{project_id}/autoscaling-policy/{cluster_id}

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Explanation

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    Constraints

    N/A

    Value range

    The value must consist of 1 to 64 characters. Only letters and digits are allowed.

    Default value

    N/A

    cluster_id

    Yes

    String

    Explanation

    Cluster ID For details about how to obtain the cluster ID, see Obtaining the MRS Cluster Information.

    Constraints

    N/A

    Value range

    The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-).

    Default value

    N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

node_group

Yes

String

Explanation

Type of the node to which an auto scaling rule applies. Currently, only task nodes support auto scaling rules.

Constraints

N/A

Value range

  • task_node_default_group: Task node

Default value

N/A

auto_scaling_policy

Yes

AutoScalingPolicy object

Explanation

The auto scaling policy. Table 3 describes these parameters.

Constraints

N/A

Table 3 AutoScalingPolicy

Parameter

Mandatory

Type

Description

auto_scaling_enable

Yes

Boolean

Explanation

Whether to enable the auto scaling rule.

Constraints

N/A

Value range

  • true: Enable the auto scaling rule.
  • false: Disable the autoscaling rule.

Default value

N/A

min_capacity

Yes

Integer

Explanation

Minimum number of nodes left in the node group.

Constraints

N/A

Value range

0-500

Default value

N/A

max_capacity

Yes

Integer

Explanation

Maximum number of nodes in the node group.

Constraints

N/A

Value range

0-500

Default value

N/A

resources_plans

No

List

Explanation

Resource plan list. For details, see Table 4. If this parameter is left blank, the resource plan is disabled.

Constraints

When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured.

exec_scripts

No

List

Explanation

List of custom scaling automation scripts. For details, see Table 5. If this parameter is left blank, a hook script is disabled.

Constraints

The number of records cannot exceed 10.

rules

No

List

Explanation

List of auto scaling rules. For details, see Table 6.

Constraints

When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. The number of records cannot exceed 10.

Table 4 ResourcesPlan

Parameter

Mandatory

Type

Description

period_type

Yes

String

Explanation

Cycle type of a resource plan. This parameter can be set to daily only.

Constraints

N/A

Value range

N/A

Default value

N/A

start_time

Yes

String

Explanation

Start time of a resource plan. The value is in the format of hour:minute.

Constraints

N/A

Value range

N/A

Default value

N/A

end_time

Yes

String

Explanation

End time of a resource plan. The format is the same as that of start_time.

Constraints

The value cannot be earlier than the start_time, and the interval between start_time and start_time cannot be less than 30 minutes.

Value range

N/A

Default value

N/A

min_capacity

Yes

Integer

Explanation

Minimum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Value range

0-500

Default value

N/A

max_capacity

Yes

Integer

Explanation

Maximum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Value range

0-500

Default value

N/A

Table 5 ScaleScript

Parameter

Mandatory

Type

Description

name

Yes

String

Explanation

Names of custom scaling automation scripts.

Constraints

N/A

Value range

The names in the same cluster must be unique.

The value can contain only digits, letters, spaces, hyphens (-), and underscores (_) and must not start with a space.

The value can contain 1 to 64 characters.

Default value

N/A

uri

Yes

String

Explanation

Path of a custom automation script. Set this parameter to an OBS bucket path or a local VM path.

  • OBS bucket path: Enter a script path manually. for example, s3a://XXX/scale.sh.
  • Local VM path: Enter a script path. The script path must start with a slash (/) and end with .sh.

Constraints

N/A

Value range

N/A

Default value

N/A

parameters

No

String

Explanation

Parameters of a custom automation script.

  • Multiple parameters are separated by space.
  • The following predefined system parameters can be transferred:
    • ${mrs_scale_node_num}: Number of the nodes to be added or removed
    • ${mrs_scale_type}: Scaling type. The value can be scale_out or scale_in.
    • ${mrs_scale_node_hostnames}: Host names of the nodes to be added or removed
    • ${mrs_scale_node_ips}: IP addresses of the nodes to be added or removed
    • ${mrs_scale_rule_name}: Name of the rule that triggers auto scaling
  • Other user-defined parameters are used in the same way as those of common shell scripts. Parameters are separated by space.

Constraints

N/A

Value range

N/A

Default value

N/A

nodes

Yes

Array of strings

Explanation

Type of a node where the custom automation script is executed. The node type can be Master, Core, or Task.

Constraints

N/A

active_master

No

Boolean

Explanation

Whether the custom automation script runs only on the active Master node.

Constraints

N/A

Value range

  • true: The custom automation script runs only on the active Master nodes.
  • false: The custom automation script can run on all Master nodes.

Default value

false

action_stage

Yes

String

Explanation

Time when a script is executed.

Constraints

N/A

Value range

  • before_scale_out: before scale-out
  • before_scale_in: before scale-in
  • after_scale_out: after scale-out
  • after_scale_in: after scale-in

Default value

N/A

fail_action

Yes

String

Explanation

Whether to continue to execute subsequent scripts and create a cluster after the custom automation script fails to be executed.

Constraints

N/A

Value range

  • continue: Continue to execute subsequent scripts.
  • errorout: Stop the action.

Default value

N/A

NOTE:
  • You are advised to set this parameter to continue in the commissioning phase so that the cluster can continue to be installed and started no matter whether the custom automation script is executed successfully.
  • The scale-in operation cannot be undone. Therefore, fail_action must be set to continue for the scripts that are executed after scale-in.
Table 6 Rule

Parameter

Mandatory

Type

Description

name

Yes

String

Explanation

Name of an auto scaling rule.

Constraints

N/A

Value range

A cluster name can contain only 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

Rule names must be unique in a node group.

Default value

N/A

description

No

String

Explanation

Description about an auto scaling rule.

Constraints

N/A

Value range

A string of 1 to 1024 characters

Default value

N/A

adjustment_type

Yes

String

Explanation

Adjustment type of an auto scaling rule.

Constraints

N/A

Value range

  • scale_out: cluster scale-out
  • scale_in: cluster scale-in

Default value

N/A

cool_down_minutes

Yes

Integer

Explanation

Cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute.

Constraints

N/A

Value range

0 to 10080. 10080 indicates the number of minutes in a week.

Default value

N/A

scaling_adjustment

Yes

Integer

Explanation

Number of nodes that can be adjusted once.

Constraints

N/A

Value range

1-100

Default value

N/A

trigger

Yes

Trigger object

Explanation

Condition for triggering a rule. For details, see Table 7.

Constraints

N/A

Table 7 Trigger

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Explanation

Metric name.

This triggering condition makes a judgment according to the value of the metric.

Constraints

N/A

Value range

The value contains a maximum of 64 characters.

Default value

N/A

metric_value

Yes

String

Explanation

Metric threshold to trigger a rule

The value must be an integer or a number with two decimal places.

Constraints

N/A

Value range

Only integers or numbers with two decimal places are allowed.

Default value

N/A

comparison_operator

No

String

Explanation

Metric judgment logic operator.

Constraints

N/A

Value range

  • LT: less than
  • GT: greater than
  • LTOE: less than or equal to
  • GTOE: greater than or equal to

Default value

N/A

evaluation_periods

Yes

Integer

Explanation

Number of consecutive five-minute periods, during which a metric threshold is reached

Constraints

N/A

Value range

1-200

Default value

N/A

Response Parameters

None

Example Request

Configure an auto scaling policy for the MRS cluster.

POST https://{endpoint}/v1.1/{project_id}/autoscaling-policy/{cluster_id}

{
  "node_group" : "task_node_analysis_group",
  "auto_scaling_policy" : {
    "auto_scaling_enable" : "true",
    "min_capacity" : "1",
    "max_capacity" : "3",
    "resources_plans" : [ {
      "period_type" : "daily",
      "start_time" : "9:50",
      "end_time" : "10:20",
      "min_capacity" : "2",
      "max_capacity" : "3"
    }, {
      "period_type" : "daily",
      "start_time" : "10:20",
      "end_time" : "12:30",
      "min_capacity" : "0",
      "max_capacity" : "2"
    } ],
    "exec_scripts" : [ {
      "name" : "before_scale_out",
      "uri" : "s3a://XXX/zeppelin_install.sh",
      "parameters" : "${mrs_scale_node_num} ${mrs_scale_type} xxx",
      "nodes" : [ "master_node_default_group", "core_node_analysis_group", "task_node_analysis_group" ],
      "active_master" : "true",
      "action_stage" : "before_scale_out",
      "fail_action" : "continue"
    }, {
      "name" : "after_scale_out",
      "uri" : "s3a://XXX/storm_rebalance.sh",
      "parameters" : "${mrs_scale_node_hostnames} ${mrs_scale_node_ips}",
      "nodes" : [ "master_node_default_group", "core_node_analysis_group", "task_node_analysis_group" ],
      "active_master" : "true",
      "action_stage" : "after_scale_out",
      "fail_action" : "continue"
    } ],
    "rules" : [ {
      "name" : "default-expand-1",
      "adjustment_type" : "scale_out",
      "cool_down_minutes" : "5",
      "scaling_adjustment" : "1",
      "trigger" : {
        "metric_name" : "YARNMemoryAvailablePercentage",
        "metric_value" : "25",
        "comparison_operator" : "LT",
        "evaluation_periods" : "10"
      }
    }, {
      "name" : "default-shrink-1",
      "adjustment_type" : "scale_in",
      "cool_down_minutes" : "5",
      "scaling_adjustment" : "1",
      "trigger" : {
        "metric_name" : "YARNMemoryAvailablePercentage",
        "metric_value" : "70",
        "comparison_operator" : "GT",
        "evaluation_periods" : "10"
      }
    } ]
  }
}
NOTE:

A new auto scaling rule will overwrite the auto scaling rule saved in the original database. If you want to modify the original rule, query the original rule first, modify the rule, and submit a modification task. For details, see Querying Cluster Details.

Example Response

Status code: 200

The operation is successful.

{
  "result" : "succeeded"
}

Status Codes

Table 8 describes the status code.

Table 8 Status code

Status Code

Description

200

The cluster has been created.

See Status Codes.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback