Configuring an Auto Scaling Rule
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
- Parameter description
Table 1 URI parameters Parameter
Mandatory
Type
Description
project_id
Yes
String
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.
cluster_id
Yes
String
Cluster ID For details about how to obtain the cluster ID, see Obtaining the MRS Cluster Information.
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
node_group |
Yes |
String |
Type of the node to which an auto scaling rule applies. Currently, only Task nodes support auto scaling rules, that is, the request value is task_node_default_group. |
auto_scaling_policy |
Yes |
AutoScalingPolicy object |
The auto scaling policy. Table 3 describes these parameters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
auto_scaling_enable |
Yes |
Boolean |
Whether to enable the auto scaling rule. |
min_capacity |
Yes |
Integer |
Minimum number of nodes left in the node group. Value range: 0 to 500 |
max_capacity |
Yes |
Integer |
Maximum number of nodes in the node group. Value range: 0 to 500 |
resources_plans |
No |
List |
Resource plan list. For details, see Table 4. If this parameter is left blank, the resource plan is disabled. When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. |
exec_scripts |
No |
List |
List of custom scaling automation scripts. For details, see Table 5. If this parameter is left blank, a hook script is disabled. |
rules |
No |
List |
List of auto scaling rules. For details, see Table 6. When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
period_type |
Yes |
String |
Cycle type of a resource plan. Currently, only the following cycle type is supported: daily |
start_time |
Yes |
String |
Start time of a resource plan. The value is in the format of hour:minute, indicating that the time ranges from 0:00 to 23:59. |
end_time |
Yes |
String |
End time of a resource plan. The value is in the same format as that of start_time. The interval between end_time and start_time must be greater than or equal to 30 minutes. |
min_capacity |
Yes |
Integer |
Minimum number of the preserved nodes in a node group in a resource plan. Value range: 0 to 500 |
max_capacity |
Yes |
Integer |
Maximum number of the preserved nodes in a node group in a resource plan. Value range: 0 to 500 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Name of a custom automation script. It must be unique in a same cluster. 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. |
uri |
Yes |
String |
Path of a custom automation script. Set this parameter to an OBS bucket path or a local VM path.
|
parameters |
No |
String |
Parameters of a custom automation script.
|
nodes |
Yes |
Array of strings |
Type of a node where the custom automation script is executed. The node type can be Master, Core, or Task. |
active_master |
No |
Boolean |
Whether the custom automation script runs only on the active Master node. The default value is false, indicating that the custom automation script can run on all Master nodes. |
action_stage |
Yes |
String |
Time when a script is executed. The following four options are supported:
|
fail_action |
Yes |
String |
Whether to continue to execute subsequent scripts and create a cluster after the custom automation script fails to be executed.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Name of an auto scaling rule. 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. |
description |
No |
String |
Description about an auto scaling rule. It contains a maximum of 1,024 characters. |
adjustment_type |
Yes |
String |
Auto scaling rule adjustment type. Possible values:
|
cool_down_minutes |
Yes |
Integer |
Cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute. Value range: 0 to 10,080. One week is equal to 10,080 minutes. |
scaling_adjustment |
Yes |
Integer |
Number of nodes that can be adjusted once. Value range: 1 to 100 |
trigger |
Yes |
Trigger object |
Condition for triggering a rule. For details, see Table 7. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
metric_name |
Yes |
String |
Metric name. This triggering condition makes a judgment according to the value of the metric. A metric name contains a maximum of 64 characters. |
metric_value |
Yes |
String |
Metric threshold to trigger a rule The parameter value can be an integer or number with two decimal places only. |
comparison_operator |
No |
String |
Metric judgment logic operator. Possible values:
|
evaluation_periods |
Yes |
Integer |
Number of consecutive five-minute periods, during which a metric threshold is reached Value range: 1 to 288 |
Response Parameters
Parameter |
Type |
Description |
---|---|---|
result |
String |
Operation result
|
Example
- Example request
{ "node_group":"task_node_default_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": "", "nodes": [ "master", "core", "task" ], "active_master": "true", "action_stage": "before_scale_out", "fail_action": "continue" },{ "name": "after_scale_out", "uri": "s3a://XXX/storm_rebalance.sh", "parameters": "", "nodes": [ "master", "core", "task" ], "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 } }] } }
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
{ "result": "succeeded" }
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot