Autoscaling ClickHouse® cluster resources

Note

This functionality is available in the Feature preview stage.

Autoscaling allows your Managed ClickHouse® cluster resources to automatically adjust depending on the cluster usage. You can configure the cluster to automatically increase the storage when it nears capacity and adjust the cluster resources to match the workload.

Autoscaling also helps you control costs because your cluster only uses the resources it needs. When creating a cluster, you don't need to allocate storage for future potential database growth from the very start. Instead, storage capacity incrementally grows together with the database size, so you only pay for what you use. Similarly, you don't need to allocate resources for potential load spikes. You can specify the amount of CPU and RAM for your current needs and then have the cluster automatically scale up and down to handle varying workloads.

How autoscaling works

Storage autoscaling

When storage autoscaling is enabled, DoubleCloud monitors how much storage is available in the cluster. When disk utilization on any host reaches 90%, it adds storage on all hosts towards the next capacity available in a given resource preset. DoubleCloud sends notification emails before storage increases.

Note

For example, you created a Managed ClickHouse® cluster with 32 GB of storage and enabled autoscaling with a maximum limit of 96 GB. When 90% of the 32 GB is used on any host, the storage automatically scales up to 48 GB. When 90% of the 48 GB is used, it scales up to 64 GB. This repeats until the storage is 96 GB.

The interval between storage increases is at least six hours. All storage increases are permanent, and the cost depends on the actual storage size.

Instance autoscaling

When instance autoscaling is enabled, DoubleCloud monitors the CPU utilization in the cluster. If the average CPU utilization on all hosts in the cluster exceeds 60% for 5 minutes, the cluster scales up towards the next available resource preset. The cluster can incrementally scale up until it reaches the maximum preset specified in the cluster configuration.

When the period of increased CPU utilization is over, the cluster returns to the base resource preset. For the cluster to scale down, the CPU usage should be under 50% of the next lower resource preset for an hour.

The minimal interval between instance autoscaling events is 15 minutes, but the actual time may be different depending on the load.

Configure autoscaling

You can configure autoscaling when creating a ClickHouse® cluster or enable it later in the cluster settings. Autoscaling is available for SSD storage and instances for both ClickHouse® and Keeper hosts.

To configure autoscaling, select the Autoscaling section when creating or editing a ClickHouse® cluster. You can enable SSD storage autoscaling, instance autoscaling, or both. The options you select in the dropdowns specify the maximum resource configuration the cluster can automatically scale to.

configure autoscaling

By default, the maximum limit is set to the next capacity available in a given resource preset.

Note

Storage can only scale up, and its increases are permanent. Instances can scale both up and down between the base resource preset and maximum limit you specify.

To enable storage autoscaling, specify the max_disk_size values for clickhouse, dedicated_keeper, or both in the ClickHouse® cluster resource configuration .

To enable instance autoscaling, specify min_resource_preset_id and max_resource_preset_id instead of resource_preset_id.

Example resource configuration:

resource "doublecloud_clickhouse_cluster" "example-clickhouse" {
  ...
  resources {
    clickhouse {
      min_resource_preset_id = "s2-c2-m8"
      max_resource_preset_id = "s2-c16-m64"
      disk_size          = 34359738368     # 32 GB in bytes
      max_disk_size      = 103079215104    # 96 GB in bytes
      ...
    }
    dedicated_keeper {
      resource_preset_id = "s2-c2-m4"
      disk_size          = 34359738368     # 32 GB in bytes
      max_disk_size      = 51539607552     # 48 GB in bytes
      ...
    }
  }
  ...
}

max_disk_size must be greater than the base storage size. If it's equal to the base storage size or not specified, autoscaling is disabled.

To enable the cluster SSD storage autoscaling, specify the max_disk_size parameter in ClusterResources.Clickhouse when creating or updating the cluster.

Note

max_disk_size must be greater than the base storage size. If it's equal to the base storage size or not specified, autoscaling is disabled.

To enable instance autoscaling, specify min_resource_preset_id and max_resource_preset_id instead of resource_preset_id in ClusterResources.Clickhouse when creating or updating the cluster.