As your data volume and computing workload grow, resources such as CPU, disk, memory, and the number of compute nodes can become a performance bottleneck. You can dynamically scale your instance online by changing the instance type and the number of compute nodes.
The following table describes how configuration changes are supported for different Resource Types of AnalyticDB for PostgreSQL.
Upgrade/Downgrade Operations | Serverless mode | Elastic storage mode |
Upgrade node specifications | Unsupported | Supported |
Downgrade node specifications | Unsupported | Supported |
Add compute nodes | Supported | Supported |
Remove compute nodes | Supported | Supported |
Usage notes
To remove compute nodes from an instance in elastic storage mode, the minor engine version must be V6.3.10.5 or later for an AnalyticDB for PostgreSQL V6.0 instance, or V7.0.1.2 or later for an AnalyticDB for PostgreSQL V7.0 instance. For more information, see View the minor engine version of an instance.
For instances in elastic storage mode with a minor engine version of V6.6.2.0 or later, or V7.0.5.0 or later, both read and write operations are supported when you add compute nodes. Earlier versions support only read operations. When you remove compute nodes, data write operations may be affected.
When you remove compute nodes from an instance in elastic storage mode, ensure that the instance has sufficient capacity to store the existing data after the scale-in operation.
Changing the compute nodes of a Serverless instance interrupts running SQL statements. These statements cannot be resumed after the change is complete.
Select a configuration change method
Upgrade or downgrade node specifications: This method changes the resources of existing nodes, such as CPU, memory, and disk, without changing the number of nodes. This method is fast because it does not involve data migration.
Add or remove compute nodes: This method adds or removes compute nodes of the same specifications. This changes the total resources and requires data rebalancing. This is a more complex operation, and the time required is proportional to the data volume. For more information about the time required for each method, see Time required for configuration changes.
When you change resource configurations, follow these principles to select a method:
View node monitoring data. If the CPU and I/O utilization of compute nodes remain high for an extended period during business hours, you should prioritize adding compute nodes. If CPU and memory resources are insufficient but I/O utilization is not high, you should prioritize upgrading node specifications to resolve the performance bottleneck more quickly.
If disk usage is high but computing resources are sufficient, you can increase only the node storage capacity when upgrading node specifications. This method saves costs by avoiding the need to add more compute nodes.
To downgrade resources, prioritize downgrading node specifications. If the specifications cannot be downgraded further, you can remove compute nodes.
Time required for configuration changes
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 process can take from 30 minutes to several hours, depending on the data volume. The time is affected by factors such as the number of tables, partitioned tables, and indexes, the compression status, the total data volume, and the instance type. You can estimate the time using this formula:
Time (min) = Total data volume (GB) / 1.25 / Number of nodes after change + Reserved time.
The reserved time, which covers steps such as resource application, is fixed at 30 minutes. For example, to scale out 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
Serverless mode supports online elastic scaling within minutes. This scaling process does not require data migration. Therefore, the scaling speed depends on the speed of resource application, not the data size. Lab test results for scaling performance are as follows:
Scaling for instances with 16 nodes or fewer takes 60 seconds or less.
Scaling for instances with more than 16 nodes takes 5 minutes or less.
Procedures
Add compute nodes
Online scale-out ensures that business operations are not affected during a configuration change. Read and write operations on all tables in the database are not interrupted. For instances in elastic storage mode, online scale-out by adding compute nodes is supported on minor engine version V6.6.2.0 or later for AnalyticDB for PostgreSQL V6.0, and on minor engine version V7.0.5.0 or later for AnalyticDB for PostgreSQL V7.0. Keep the following points in mind:
During the configuration change, data is redistributed sequentially for all tables. For tables that are currently being redistributed, all queries and the INSERT, COPY, DELETE, and UPDATE commands are supported. However, DDL commands and the VACUUM command are not supported. If you execute a DDL command, an error is reported:
TRUNCATE t1;
ERROR: Unsupport 'TRUNCATE TABLE' command during online expansion on 't1'Large volumes of data writes and updates will extend the time required for the configuration change. To optimize the speed, a write lock is applied to frequently written tables after a certain period. This may briefly affect read and write operations on those tables. You can monitor the scale-out progress in real time in the console.
For instances with earlier minor engine versions, online scaling is not supported when you add compute nodes. This process may interrupt read and write operations on tables. We recommend that you 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 Notice dialog box, select I am aware of the impact of this operation and agree to continue it. and then click OK.
NoteThis step is required only for Serverless instances.
On the Upgrade/Downgrade page, select an appropriate value for Number Of Nodes (segment), select the Terms of Service, and then click Buy Now.
WarningInstances in elastic storage mode: Tables that are being redistributed become read-only during the configuration change. Newer versions support both read and write operations. The redistribution time depends on the table size. Plan the task accordingly.
Serverless instances: After you submit the configuration change task, running SQL statements are interrupted and cannot be resumed.
Return to the Instance List page. Wait for the status of the target instance to change to Running.
For tables with high performance requirements, you can execute the following SQL statement to prefetch data and accelerate access.
SELECT count(*) FROM <hot_table>;NoteYou need to prefetch data only for Serverless instances.
Scaling nodes in or out involves five steps: resource initialization, system table metadata synchronization, locking to protect and modify data distribution information, unlocking and clearing resources, and asynchronous local cache recovery. Because the local cache is restored asynchronously, the cache hit ratio may be low for a short period. Prefetching data can accelerate access.
Remove compute nodes
When you remove compute nodes from an instance in elastic storage mode, ensure that the instance specifications after the scale-in can accommodate the existing data. During the scale-in period, you should reduce data update and write operations on the instance.
- 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 Notice dialog box, select I am aware of the impact of this operation and agree to continue it. and then click OK.
On the Upgrade/Downgrade page, select an appropriate value for Number Of Nodes (segment), select the Terms of Service, and then click Buy Now.
WarningInstances in elastic storage mode: Tables that are being redistributed become read-only during the configuration change. The redistribution time depends on the table size. Plan the task accordingly.
Serverless instances: After you submit the configuration change task, running SQL statements are interrupted and cannot be resumed.
Return to the Instance List page. Wait for the status of the target instance to change to Running.
For tables with high performance requirements, you can execute the following SQL statement to prefetch data and accelerate access.
SELECT count(*) FROM <hot_table>;NoteYou need to prefetch data only for Serverless instances.
Scaling nodes in or out involves five steps: resource initialization, system table metadata synchronization, locking to protect and modify data distribution information, unlocking and clearing resources, and asynchronous local cache recovery. Because the local cache is restored asynchronously, the cache hit ratio may be low for a short period. Prefetching data can accelerate 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 Upgrade/Downgrade page, modify the following configurations.
Configuration
Description
Instance Resource Type
The resource type of the current instance. This cannot be changed.
Node Specifications (segment)
Select appropriate node specifications as needed.
Node Storage Capacity (segment)
Select an appropriate node storage capacity as needed.
WarningThe database becomes read-only during the node specification change. Plan the task accordingly.
The instance supports read and write operations when only the node storage capacity is changed.
Select the Terms of Service, and then click Buy Now.
Return to the Instance List 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 Upgrade/Downgrade page, modify the following configurations.
Configuration
Description
Instance Resource Type
The resource type of the current instance. This cannot be changed.
Node Specifications (segment)
Select appropriate node specifications as needed.
Node Storage Capacity (segment)
Reducing the node storage capacity is not supported.
NoteThis configuration item is not available for Basic Edition instances in elastic storage mode.
WarningThe database becomes read-only during the node specification change. Plan the task accordingly.
The instance supports read and write operations when only the node storage capacity is changed.
Select the Terms of Service, and then click Buy Now.
Return to the Instance List page. Wait for the status of the target instance to change to Running.