Scale compute nodes
When your data volume and workload grow, your compute resources, such as CPU, disk, memory, and the number of compute nodes, can become a performance bottleneck. To address this, you can dynamically scale your instance by changing node specifications or the number of compute nodes.
The support for scaling compute nodes varies by the Instance resource type for AnalyticDB for PostgreSQL. The following table describes the support details.
|
Operation |
Serverless mode |
Elastic storage mode |
|
Upgrade node specifications |
Not supported |
Supported |
|
Downgrade node specifications |
Not supported |
Supported |
|
Add compute nodes |
Supported |
Supported |
|
Remove compute nodes |
Supported |
Supported |
Usage notes
-
For an instance in elastic storage mode, you can remove compute nodes only if the minor engine version is V6.3.10.5 or later for V6.0, or V7.0.1.2 or later for V7.0. For more information about how to check the version, see View the minor engine version of an instance.
-
For instances in elastic storage mode with minor engine version V6.6.2.0 or later (for V6.0) or V7.0.5.0 or later (for V7.0), read and write operations are supported when you add compute nodes. For earlier versions, only read operations are supported. When you remove compute nodes, write operations might be affected.
-
When you remove compute nodes from an instance in elastic storage mode, make sure the remaining capacity is sufficient for your existing data.
-
When you scale compute nodes for a serverless mode instance, running SQL queries are interrupted and cannot be resumed.
Choose a scaling method
-
Scaling node specifications up or down changes the CPU, memory, and disk resources of existing nodes without changing the number of nodes. This method does not require data migration and is relatively fast.
-
Adding or removing compute nodes changes the total resources by adding or deleting nodes of the same specification. This operation requires data redistribution, a process whose duration is proportional to the data volume. For time estimates of the two scaling methods, see Scaling time.
When you need to scale resources, follow these principles to choose a scaling method:
-
Check the node monitoring data. If CPU and I/O utilization of compute nodes remains high for extended periods during business hours, prioritize adding compute nodes. If CPU or memory resources are insufficient but I/O utilization is low, prioritize upgrading node specifications to resolve the performance bottleneck faster.
-
If disk usage is high but compute resources are sufficient, you can choose to increase only the node storage capacity when you upgrade node specifications. This method saves costs by avoiding the need to add new compute nodes.
-
If the specifications cannot be downgraded further, remove compute nodes.
Scaling time
Upgrading or downgrading node specifications takes about 10 minutes. The time required to add or remove compute nodes depends on the instance mode:
-
elastic storage mode
The scaling process can take from 30 minutes to dozens of hours, depending on factors such as the number of tables, number of partitioned tables, number of indexes, whether data compression is enabled, total data volume, and node specifications. You can use the following formula to estimate the time:
Scaling time (min) = Total data volume (GB) / 1.25 / Number of nodes after scaling + Reserved time.
The reserved time is a fixed 30 minutes for steps such as resource provisioning. For example, to scale an instance with 1 TB of data to 16 nodes, the estimated time is 1024 / 1.25 / 16 + 30 = 81 minutes.
NoteWhen you add compute nodes:
-
For instances with a minor engine version earlier than V6.6.2.0 or V7.0.5.0, tables that are being redistributed may become temporarily unavailable for read and write operations. You can retry the operation later.
-
For instances with a minor engine version of V6.6.2.0 or later, or V7.0.5.0 or later, read and write operations are not interrupted when you add compute nodes.
-
-
serverless mode
The serverless mode supports online elastic scaling within minutes. This process does not require data migration, so the speed depends on resource provisioning, not data size. Lab tests show the following scaling performance:
-
Scaling for instances with up to 16 nodes takes no more than 60 seconds.
-
Scaling for instances with more than 16 nodes takes no more than 5 minutes.
-
Procedure
Add compute nodes
Online scaling lets you scale an instance without disrupting your services, meaning that all tables in the database remain available for read and write operations. For elastic storage mode, instances with minor engine version V6.6.2.0 or later (for V6.0) and V7.0.5.0 or later (for V7.0) support online scaling when you add compute nodes. Key points to note:
-
During scaling, all tables are redistributed one by one. Tables not currently undergoing redistribution are unaffected. For tables being redistributed, all queries and the INSERT, COPY, DELETE, and UPDATE commands are supported. DDL and VACUUM commands are not supported. If you run a DDL command on a table that is being redistributed, an error is returned:
TRUNCATE t1;
ERROR: Unsupport 'TRUNCATE TABLE' command during online expansion on 't1'
Large volumes of data writes and updates can prolong the scaling time. To optimize speed, a write lock may be placed on frequently written tables, briefly affecting their read and write operations. You can monitor the scaling progress in real time in the console.
For instances of earlier versions, online scaling is not supported when you add compute nodes. This can interrupt read and write operations on tables. Perform this operation during off-peak hours.
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
-
Find the target instance. In the Actions column, choose .
-
In the Info dialog box, select I am aware of the impact of this operation and agree to continue it. and click OK.
NoteThis step is required only for serverless mode instances.
-
On the Change Configurations page, select an appropriate value for Number of nodes (segment), select the terms of service, and click Buy Now.
Warning-
Elastic storage mode instances: Tables that are being redistributed become read-only. For newer versions, both read and write operations are supported. The redistribution time depends on the table size. Plan the scaling task accordingly.
-
Serverless mode instances: After you submit the scaling task, running SQL queries are interrupted and cannot be resumed.
-
-
Return to the Instances page. Wait for the status of the target instance to change to Running.
-
Run the following SQL statement to pre-warm data for high-performance tables, which accelerates data access.
SELECT count(*) FROM <hot_table>;Note-
Data pre-warming is required only for serverless mode instances.
-
Scaling nodes in or out involves five steps: initializing resources, synchronizing system table metadata, acquiring locks to protect and modify data distribution information, releasing locks and clearing resources, and asynchronously recovering the local cache. Because the local cache is restored asynchronously, the cache hit rate may be temporarily low. Pre-warming data accelerates subsequent access.
-
Remove compute nodes
When you remove compute nodes from an instance in elastic storage mode, make sure the remaining capacity is sufficient for your data. Reduce data update and write operations on the instance during the scale-in period.
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
-
Find the target instance. In the Actions column, choose .
-
In the Info dialog box, select I am aware of the impact of this operation and agree to continue it. and click OK.
-
On the Change Configurations page, select an appropriate value for Number of nodes (segment), select the terms of service, and click Buy Now.
Warning-
Elastic storage mode instances: Tables that are being redistributed become read-only. The redistribution time depends on the table size. Plan the scaling task accordingly.
-
Serverless mode instances: After you submit the scaling task, running SQL queries are interrupted and cannot be resumed.
-
-
Return to the Instances page. Wait for the status of the target instance to change to Running.
-
Run the following SQL statement to pre-warm data for high-performance tables, which accelerates data access.
SELECT count(*) FROM <hot_table>;Note-
Data pre-warming is required only for serverless mode instances.
-
Scaling nodes in or out involves five steps: initializing resources, synchronizing system table metadata, acquiring locks to protect and modify data distribution information, releasing locks and clearing resources, and asynchronously recovering the local cache. Because the local cache is restored asynchronously, the cache hit rate may be temporarily low. Pre-warming data accelerates subsequent access.
-
Upgrade node specifications
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
-
Find the target instance. In the Actions column, choose .
-
On the Change Configurations page, modify the following configurations.
Parameter
Description
Instance resource type
The resource type of the current instance. This parameter cannot be changed.
Node specifications (segment)
Select the appropriate node specifications based on your requirements.
Node storage capacity (segment)
Select the appropriate compute node storage capacity based on your requirements.
Warning-
During node specification scaling, the database is read-only. Plan the scaling task accordingly.
-
However, if you only change the node storage capacity, the instance continues to support read and write operations.
-
-
Select the terms of service, and click Buy Now.
-
Return to the Instances page. Wait for the status of the target instance to change to Running.
Downgrade node specifications
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
-
Find the target instance. In the Actions column, choose .
-
On the Change Configurations page, modify the following configurations.
Parameter
Description
Instance resource type
The resource type of the current instance. This parameter cannot be changed.
Node specifications (segment)
Select the appropriate node specifications based on your requirements.
Node storage capacity (segment)
Reducing the node storage capacity is not supported.
NoteThis configuration is not available for Basic Edition instances in elastic storage mode.
Warning-
During node specification scaling, the database is read-only. Plan the scaling task accordingly.
-
However, if you only change the node storage capacity, the instance continues to support read and write operations.
-
-
Select the terms of service, and click Buy Now.
-
Return to the Instances page. Wait for the status of the target instance to change to Running.