All Products
Search
Document Center

ApsaraDB for ClickHouse:Vertical and horizontal scaling for Community-Compatible Edition clusters

Last Updated:Jul 03, 2026

To adapt to changing business requirements, you can adjust the configuration or size of your Alibaba Cloud ClickHouse Community-Compatible Edition cluster. You can perform vertical and horizontal scaling on your Alibaba Cloud ClickHouse cluster to achieve an optimal balance between cost and performance.

Overview of vertical and horizontal scaling

Vertical scaling is faster and less disruptive to your business than horizontal scaling. If your cluster's performance is insufficient, consider vertical scaling first.

Scaling method

Use cases

How it works

Impact

Actions

Vertical scaling

Adjusts node resources when CPU, memory, or disk capacity is insufficient or over-provisioned.

Increases or decreases the node specifications, storage capacity, and ZooKeeper specifications for a Alibaba Cloud ClickHouse Community-Compatible Edition cluster, adjusting its computing power, storage capacity, and distributed coordination capabilities.

Note

You cannot use vertical scaling to reduce storage capacity. The following solutions are available to reduce storage capacity:

  • For a multi-node instance, you can scale in a node to reduce storage capacity based on your business requirements.

  • For a single-node instance, you can create a new instance and migrate the data to reduce storage capacity.

Upgrading the storage type or increasing the storage capacity for an Alibaba Cloud ClickHouse Community-Compatible Edition cluster does not affect the instance (this applies only to instances created after December 1, 2021). However, changing the cluster or ZooKeeper specifications restarts the cluster.

Important
  • Vertical scaling takes 5 to 10 minutes. The time required to restart a cluster depends on the data volume. The more databases, tables, and cold data a cluster has, the longer the restart takes.

  • For a dual-replica cluster, scaling may cause transient connection interruptions as requests switch between replicas. Perform scaling during off-peak hours and ensure that your application has a retry mechanism.

  • A single-replica cluster is unavailable throughout the scaling process. Perform this operation during off-peak hours or when write operations are suspended, and ensure your application has a retry mechanism.

  • If you change ZooKeeper specifications during peak hours, inconsistencies may occur between table metadata and the actual data. Perform this operation during off-peak hours or when write operations are suspended.

Scale up or scale down

Scale-out

  • Scale-out with data migration: Use this method when cluster data needs to be redistributed after scaling out.

  • Simple scale-out:

    Use this method when your cluster meets the following conditions:

    • Before the cluster is scaled out, data is written directly to local tables or to distributed tables whose sharding key is set to rand.

    • Data rebalancing across nodes is not required.

Important

Do not use simple scale-out for clusters that contain tables using engines such as ReplacingMergeTree, CollapsingMergeTree, or VersionedCollapsingMergeTree. Data in these types of tables can be merged only on the same node. Simple scale-out disperses data that needs to be merged across different nodes, preventing it from being merged.

Scale-out with data migration: Increases the number of nodes in an Alibaba Cloud ClickHouse Community-Compatible Edition cluster to horizontally scale its computing power. Existing data is migrated and redistributed.

Simple scale-out: Increases the number of nodes in an Alibaba Cloud ClickHouse Community-Compatible Edition cluster to horizontally scale its computing power. This method is used when data is written directly to local tables and data rebalancing between nodes is not required.

  • DDL operations are prohibited during the entire scale-out process.

  • CPU and memory usage of the cluster increases during the scale-out process. The estimated resource overhead is less than 5 CPU cores and 20 GB of memory per node.

  • After the scale-out is complete, a period of high-frequency merge operations will follow. This increases I/O usage and can lead to increased latency for business requests.

Scale out and scale in

Scale-in

  • Standard scale-in:

    • Reduces the number of nodes to save costs.

    • Nodes are taken offline randomly. You cannot specify which nodes to remove.

  • Scale in by specifying nodes: Takes specified nodes offline for clusters with large storage specifications.

Reduces the number of nodes in an Alibaba Cloud ClickHouse Community-Compatible Edition cluster to lower costs.

  • DDL operations are prohibited during the entire scale-in process.

  • CPU and memory usage of the cluster increases during the scale-in process. The estimated resource overhead is less than 5 CPU cores and 20 GB of memory per node.

  • After the scale-in is complete, a period of high-frequency merge operations will follow. This increases I/O usage and can lead to increased latency for business requests.

Scale out and scale in

Prerequisites

  • The cluster is an Alibaba Cloud ClickHouse Community-Compatible Edition cluster.

  • The cluster status is Running.

  • The cluster has no unpaid renewal orders.

    Note

    Log on to the Alibaba Cloud ClickHouse console. In the upper-right corner of the page, choose Fee > Expenses and Costs. In the left-side navigation pane, click Order Management and complete the payment or cancel the order.

Usage notes

  • Vertical scaling: You can change the ZooKeeper specifications only for Alibaba Cloud ClickHouse Community-Compatible Edition clusters that were created after December 1, 2021. For information about the pricing of ZooKeeper specifications, see ZooKeeper specification pricing for Community-Compatible Edition.

  • Horizontal scaling:

    • When you scale out a cluster with MergeTree-family engine tables, the system migrates existing data to the new cluster and automatically redistributes it.

      Supported content for migration:

      • Databases, data dictionaries, and materialized views.

      • table schema: all table schemas except those for tables that use the Kafka or RabbitMQ engine.

      • Data: Data from tables that use MergeTree-family engines is incrementally migrated.

      Unsupported content for migration:

      • Table schemas and data for Kafka and RabbitMQ engine tables.

        Important

        During a configuration change, data is migrated to a new instance, and traffic is eventually switched to the new instance. To prevent data from being split between Kafka and RabbitMQ, remove the Kafka and RabbitMQ engine tables from the source cluster first. Re-create them after the configuration change is complete.

      • Data in non-MergeTree tables, such as external tables and Log-family tables.

      Important

      During the scaling process, you must manually handle the unsupported content as described in the procedure.

    • DDL operations are prohibited during the entire horizontal scaling process. Failure to follow this rule may result in data validation failures and cause the scaling to fail.

    • After a scale-out, the internal node IP addresses change. If your application relies on node IP addresses for data writes and access, you must obtain the new VPC CIDR block of the cluster. For more information, see Obtain the VPC CIDR block of a cluster.

    • Only local disk-based clusters support scaling in by specifying nodes. In this mode, data on the nodes that are taken offline is lost. In standard scale-in mode, the system does not lose data but redistributes it.

  • After the cluster configuration is changed, a period of high-frequency merge operations will follow. This increases I/O usage and can lead to increased latency for business requests. Plan in advance to mitigate the potential impact of request latency. For information about how to calculate the merge duration, see Calculate the merge duration after migration.

  • During the cluster configuration change, CPU and memory usage increases. The estimated resource overhead is less than 5 CPU cores and 20 GB of memory per node.

Billing

After you change the cluster configuration, the fees change. The actual cost displayed in the console prevails. For more information, see Billing for configuration changes.

Scale up and scale down

Important

For information about the impacts of vertical scaling, see Overview of vertical and horizontal scaling and Usage notes.

  1. Log on to the Alibaba Cloud ClickHouse console. In the upper-left corner of the page, select the region where your cluster is located.

  2. On the Clusters page, click the Clusters of Community-compatible Edition.

  3. In the Actions column for the target cluster, click Change Configurations.

  4. In the Change Configurations dialog box, select Scale Up or Scale Down, and click OK.

  5. On the Change Specification or Scale Down page, select the desired configurations based on your business requirements.

    Note
    • You cannot modify the Storage Capacity or Storage Type and the Specification at the same time when you Change Specification.

    • By default, clusters come with ZooKeeper specifications of 4 CPU cores and 8 GB of memory. On the Monitoring and Alerting page, view ZooKeeper metrics on the Cluster Monitoring panel to check for resource bottlenecks. If the default specifications are insufficient, scale up promptly.

  6. Click Buy and Start and complete the payment as prompted.

  7. On the Paid page, click Console.

  8. On the Clusters of Community-compatible Edition, view the status of the target cluster in the Status column.

    Note
    • After you change the Storage Capacity, the change takes effect immediately, and the cluster status remains Running.

    • After you change the Specification and ZooKeeper Specifications, wait about 10 to 15 minutes. The scale-up or scale-down operation is successful when the cluster status changes from Changing Specification to Running.

Scale out and scale in

Important

For information about the impacts of horizontal scaling, see Overview of vertical and horizontal scaling and Usage notes.

Step 1: Record and remove Kafka/RabbitMQ tables

The scaling feature in the console cannot directly migrate Kafka and RabbitMQ engine tables. Before you scale the cluster, you must record the DDL statements for these tables and remove them from the cluster to avoid interfering with the scaling task.

  1. Log on to the cluster and run the following statement to query all Kafka and RabbitMQ engine tables and their downstream dependencies.

    /*
    create_table_query: The table definition statement.
    dependencies_database: The database that depends on the table.
    dependencies_table: The name of the table that depends on the table.
    You can use dependencies_database and dependencies_table to identify materialized views that depend on Kafka/RabbitMQ tables.
    */
    SELECT * FROM system.tables WHERE engine IN ('RabbitMQ', 'Kafka');
  2. View the materialized view definition to check if its target table is an implicit table.

    /*
    View the materialized view definition.
    If the target table of the materialized view is an implicit table, pay special attention to the following:
    When you delete the materialized view, the implicit table is also deleted, resulting in data loss.
    Example: If the TO clause is not specified in CREATE MATERIALIZED VIEW [db.]table_name [TO[db.]name],
    the system automatically creates an implicit table in the format '.inner_id.<TABLE_UUID>' or '.inner.<TABLE>'.
    */
    SELECT * FROM system.tables WHERE database='<DATABASE>' AND name = '<MATERIALIZED_VIEW_NAME>';
  3. If a materialized view was created without a TO clause, the system automatically generates an implicit target table prefixed with .inner or .inner_id. These implicit tables are migrated to the new nodes during scaling, but due to internal naming mechanisms, directly re-creating the original materialized view may cause naming conflicts. Therefore, you must first rename the implicit target tables to regular table names.

    -- Rename the implicit target table to a regular table name (execute on all nodes).
    RENAME TABLE <database>.`.inner_id.<uuid>` TO <database>.<new_target_table_name> ON CLUSTER default;
  4. Remove the materialized views and Kafka/RabbitMQ engine tables.

    Important

    You must remove the materialized views that reference the Kafka/RabbitMQ tables before you remove the Kafka/RabbitMQ engine tables. Otherwise, the scaling operation fails.

    -- Remove the materialized views first.
    DROP TABLE <database>.<materialized_view_name> ON CLUSTER default;
    
    -- Then, remove the Kafka/RabbitMQ engine tables.
    DROP TABLE <database>.<kafka_or_rabbitmq_table_name> ON CLUSTER default;
Important

Make sure to save all recorded DDL statements. You will need to re-create these tables on the scaled cluster later. If you performed a RENAME operation, use the TO clause to point to the renamed target table when you re-create the materialized view. For more information, see CREATE MATERIALIZED VIEW.

If the cluster does not contain Kafka/RabbitMQ engine tables, you can skip Step 1, Step 4, Step 5, and Step 6, and start from Step 2.

Step 2: Back up data of non-MergeTree tables

  1. Log on to the cluster and run the following statement to identify the non-MergeTree tables that require data migration.

    SELECT
        `database` AS database_name,
        `name` AS table_name,
        `engine`
    FROM `system`.`tables`
    WHERE (`engine` NOT LIKE '%MergeTree%') AND (`engine` != 'Distributed') AND (`engine` != 'MaterializedView') AND (`engine` NOT IN ('Kafka', 'RabbitMQ')) AND (`database` NOT IN ('system', 'INFORMATION_SCHEMA', 'information_schema')) AND (`database` NOT IN (
        SELECT `name`
        FROM `system`.`databases`
        WHERE `engine` IN ('MySQL', 'MaterializedMySQL', 'MaterializeMySQL', 'Lazy', 'PostgreSQL', 'MaterializedPostgreSQL', 'SQLite')
    ))
  2. Back up the data.

    Back up the business data in the non-MergeTree tables. For more information, see Back up data to OSS.

Step 3: Scale in the console

  1. Log on to the Alibaba Cloud ClickHouse console. In the upper-left corner of the page, select the region where your cluster is located.

  2. On the Clusters page, click the Clusters of Community-compatible Edition.

  3. In the Actions column for the target cluster, click Change Configurations.

  4. In the Change Configurations dialog box, select Scale Out or Scale In, and click OK.

  5. In the scale-out or scale-in check window, view the check status.

    Note

    When you enter the check window for Scale Out, Migration Expansion is selected by default. To select Simple Expansion, click Previous on this page. In the Scale-out dialog box, select Simple Expansion and click Next to go to the Change Specification page.

    If the cluster contains Kafka/RabbitMQ engine tables, perform Step 4 to re-create the Kafka/RabbitMQ engine tables on the cluster when the scaling task enters the Data Migration stage (after the table schema migration is complete). This allows incremental data to resume flowing and be synchronized to the new nodes.

    Before the configured write suspension window starts, perform Step 5 to remove the Kafka/RabbitMQ engine tables and their downstream materialized views from the cluster. This prevents message backlogs during the write suspension window from causing data inconsistencies.

    • If the check is successful, click Next.

    • If the check fails, fix the issue as prompted on the page and click Retry Detection. After the check is successful, click Next.

      Common reasons for a scale-out check failure include:

      • Missing unique distributed table: A local table does not have a corresponding distributed table. You must create one.

      • The corresponding distributed table is not unique: A local table has more than one distributed table. Remove the extra distributed tables and keep only one.

      • Unsupported Kafka/RabbitMQ engine tables: The cluster contains Kafka or RabbitMQ engine tables. You must remove them.

      • Non-replicated MergeTree tables in a multi-replica instance: Data is inconsistent between replicas, which causes data migration errors during scaling.

      • The columns of the distributed table and the local table are inconsistent: You must make the columns consistent. Otherwise, data migration errors will occur during scaling.

      • The table is missing on some nodes: You must create tables with the same name on different shards. For the inner table of a materialized view, we recommend that you rename the inner table and then re-create the materialized view to point to the renamed inner table. For more information, see The inner table of a materialized view is inconsistent across shards.

  6. On the Change Specification or Scale Down page, configure the number of Server Nodes and the write suspension window.

    Note

    A write suspension window is a time period configured by the customer during which the kernel is allowed to stop writing. The internal migration logic determines whether to suspend writes based on the following logic: If the current time is within the write suspension window and the remaining data can be migrated within 10 minutes, the system automatically enters the write suspension state. During the suspension, the backend continues to migrate data until all data is synchronized. After the migration is complete, the system automatically exits the write suspension state.

    Data migration occurs during cluster scaling. To ensure a successful migration, the write suspension window must meet the following requirements:

    • We recommend that you set the write suspension window to at least 30 minutes.

    • The scaling must be completed within 5 days after the configuration change is created. Therefore, the end time of the write suspension window for the source cluster must be no later than the current date + 5 days.

    • To minimize the impact on your business, we recommend that you set the write suspension window to off-peak hours.

  7. Click Buy and Start and complete the payment as prompted.

  8. On the Purchase successful page, click Console.

  9. On the Clusters of Community-compatible Edition, view the status of the target cluster in the Status column.

Note

Horizontal scaling is expected to take 30 minutes or more. The duration depends on the data volume. The cluster status in the console shows the actual task execution status.

Step 4: Re-create Kafka/RabbitMQ tables

When the scaling task enters the Data Migration stage (after the table schema migration is complete), use the DDL statements that you saved to re-create the Kafka/RabbitMQ engine tables and their downstream materialized views. After re-creation, incremental data resumes flowing and automatically synchronizes to the new cluster nodes.

Important

If you performed a RENAME operation on implicit target tables in Step 1, use the TO clause to point to the renamed target table when you re-create the materialized view. For more information about the TO clause, see CREATE MATERIALIZED VIEW.

-- Re-create Kafka/RabbitMQ engine tables.
CREATE TABLE <database>.<kafka_or_rabbitmq_table_name> (...)
ENGINE = Kafka/RabbitMQ
SETTINGS ...;

-- Re-create the materialized view (use the TO clause to point to the renamed target table).
CREATE MATERIALIZED VIEW <database>.<materialized_view_name> TO <database>.<new_target_table_name>
AS SELECT ... FROM <database>.<kafka_or_rabbitmq_table_name>;

Step 5: Remove Kafka/RabbitMQ tables before write suspension

Before the configured write suspension window starts, remove the Kafka/RabbitMQ engine tables and their downstream materialized views to stop incremental data writes and ensure final data synchronization consistency.

-- Remove materialized views first.
DROP TABLE <database>.<materialized_view_name> ON CLUSTER default;

-- Then, remove Kafka/RabbitMQ engine tables.
DROP TABLE <database>.<kafka_or_rabbitmq_table_name> ON CLUSTER default;

Step 6: Re-create Kafka/RabbitMQ tables after scaling

After the scaling task is complete, use the DDL statements that you saved to re-create the Kafka/RabbitMQ engine tables and their downstream materialized views on the scaled cluster to restore the incremental data consumption pipeline.

Important

If you performed a RENAME operation on implicit target tables in Step 1, use the TO clause to point to the renamed target table when you re-create the materialized view. For more information about the TO clause, see CREATE MATERIALIZED VIEW.

-- Re-create Kafka/RabbitMQ engine tables.
CREATE TABLE <database>.<kafka_or_rabbitmq_table_name> (...)
ENGINE = Kafka/RabbitMQ
SETTINGS ...;

-- Re-create the materialized view (use the TO clause to point to the renamed target table).
CREATE MATERIALIZED VIEW <database>.<materialized_view_name> TO <database>.<new_target_table_name>
AS SELECT ... FROM <database>.<kafka_or_rabbitmq_table_name>;

Step 7: Migrate data of non-MergeTree tables

Log on to the cluster and use OSS to migrate the data that you backed up in Step 2. For more information, see Import data from OSS.