This topic describes how to set a scaling policy for the resources of a serverless cluster.
Scaling
The metrics for triggering scaling vary based on parameter configurations and serverless configurations. You can specify thresholds for CPU scaling, but cannot change thresholds for other metrics.
Trigger conditions for scale-up and scale-out
Scale-up
PolarDB monitors the CPU utilization, memory usage, and other kernel metrics of the primary node and read-only nodes. During a monitoring cycle, the scale-up of serverless resources is triggered when one of the following conditions is met:
When the CPU utilization of a single node is higher than the default scale-up threshold 80% or a custom threshold, the scale-up of the CPU specifications of the node is triggered.
When the memory usage of a single node is higher than 90%, the scale-up of the memory specifications of the node is triggered.
When the specifications of a read-only node are less than half of the specifications of the primary node, the scale-up of the specifications of the read-only node is triggered. For example, if the specifications of a read-only node are 4 PolarDB Capacity Units (PCUs) and the specifications of the primary node are 10 PCUs, the specifications of the read-only node are scaled up to at least 5 PCUs.
Scale-out
When a read-only node of a cluster is scaled up to the maximum specifications and the business workloads are still higher than the threshold for a scale-up (CPU utilization is higher than the default threshold 80% or the specified threshold), the scale-out of read-only nodes is triggered.
Trigger conditions for scale-down
When the CPU utilization of a single node is lower than the default scale-down threshold 50% or a custom threshold and the memory usage is lower than 80%, the scale-down of the node is triggered.
Usage notes
The maximum number of connections to a serverless cluster is 100,000, and the maximum IOPS of a serverless cluster is 84,000.
The In-Memory Column Index (IMCI) feature is supported for serverless clusters that contain at least one read-only node. Before you can add read-only column store nodes to a serverless cluster, you must set the Minimum Read-only Nodes parameter to 1 for the serverless cluster.
Configure serverless parameters
Serverless clusters are billed and scaled in PCUs. One PCU is approximately equal to 1 core and 2 GB of memory. The number of PCUs dynamically changes within the specified range based on your workloads.
When the workloads of a serverless cluster suddenly increase, the nodes of the cluster are scaled step by step to approach the expected specifications, instead of one step at a time. The minimum step size for node scaling is 0.5 PCUs. To quickly adapt to the current workloads, the next scaling step size increases based on the current number of PCUs per node.
Current parameters
The number of nodes dynamically changes within the specified range based on your workloads.
Log on to the PolarDB console.
In the upper-left corner, select the region in which the cluster is deployed.
Find the cluster and click its ID.
In the Database Nodes section of the Basic Information page, click Serverless Configuration.
In the Configure Serverless-related Parameters dialog box, click Edit to the right of the Current Parameters parameter to configure the following parameters:
Maximum Resources for Single Node: the maximum number of PCUs per node in the cluster. Valid values: 0 PCU to 32 PCUs.
Minimum Resources for Single Node: the minimum number of PCUs per node in the cluster. Valid values: 0 PCU to 32 PCUs.
Maximum Read-only Nodes: the maximum number of read-only nodes that can be added. Valid values: 0 to 15.
Minimum Read-only Nodes: the minimum number of read-only nodes that can be added. Valid values: 0 to 15.
Read-only Column Store Nodes: the maximum number of read-only column store nodes that can be added. Valid values: 0 to 15.
NoteYou can modify the advanced parameters based on the resource pressure of serverless clusters.
Scan Interval: In Sensitive mode, serverless-enabled PolarDB clusters with defined specifications respond to workloads in a faster manner, which reduces the observation window and execution period of the clusters. You can select Standard or Sensitive from the Scan Interval drop-down list.
Maximum CPU Resources for Elastic Upgrade: the CPU scale-up threshold for the cluster. Valid values: 40% to 100%.
Minimum CPU Resources for Elastic Upgrade: the CPU scale-down threshold for the cluster. Valid values: 10% to 70%. The difference between the CPU scale-up threshold and CPU scale-down threshold must be greater than or equal to 30%.
Click OK.
Recurring policies
When you delete a recurring policy for serverless resources, you cannot undo the task that is being executed in the current policy. The tasks that have not been executed are deleted. Proceed with caution.
If you disable the serverless feature, recurring policies and scheduled tasks are deleted. Proceed with caution.
Log on to the PolarDB console.
In the upper-left corner, select the region in which the cluster is deployed.
Find the cluster and click its ID.
In the Database Nodes section of the Basic Information page, click Serverless Configuration.
In the Configure Serverless-related Parameters dialog box, click + Add Lifecycle Policy and configure the parameters that are described in the following table.
Parameter
Description
Maximum Resources for Single Node
Valid values: 1 to 16 PCUs.
Minimum Resources for Single Node
Valid values: 1 to 16 PCUs. The value of the Minimum Resources for Single Node parameter must be less than or equal to the value of the Maximum Resources for Single Node parameter.
Maximum Read-only Nodes
Valid values: 0 to 15.
Minimum Read-only Nodes
Valid values: 0 to 15. The value of the Minimum Read-only Nodes parameter must be less than or equal to the value of the Maximum Read-only Nodes parameter.
Read-only Column Store Nodes
Valid values: 0 to 15.
Start/End Time
The validity period of the recurring policy.
Policy scheduling
The scheduling settings of the recurring policy. Valid values for the options of the Every parameter:
Month: Positive and Last.
Valid values for the Week option: Monday to Sunday.
Hour: 0 to 23. Minute: 0 and 30.
NoteYou can modify the advanced parameters based on the resource pressure of serverless clusters.
Click OK.
Query scheduled tasks
After a recurring policy is created, scheduled tasks are automatically generated based on the policy.
You can use one of the following methods to query scheduled tasks:
After a recurring policy is created for a cluster, you can view scheduled tasks in the Pending Scheduled and Failed Tasks section on the Basic Information page of the cluster.
Choose Task Management > Scheduled Tasks on the PolarDB console to view scheduled tasks.
Example
If you want to scale up 5 PCUs at 9:30 and scale down 1 PCU at 22:00 every business day (Monday to Friday) from August 1 to September 30, you can configure the settings as shown in the following figures.