> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Article discussing the Scheduled Scaling feature in ClickHouse Cloud

# Scheduled scaling

export const Image = ({img, alt, size = "lg", background}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  const backgroundColor = background === "white" ? "white" : background === "black" ? "rgb(31 31 28)" : undefined;
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} style={{
    backgroundColor
  }} />
      </Frame>
    </div>;
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <span>Beta</span>
            </a>;
  }
  return <a href="https://clickhouse.com/docs/reference/settings/beta-and-experimental-features#beta-features" className="betaBadge">
            <span>Beta feature</span>
        </a>;
};

<BetaBadge />

ClickHouse Cloud services automatically scale based on CPU and memory utilization, but many workloads follow predictable patterns — daily ingestion spikes, batch jobs that run overnight, or traffic that drops sharply on weekends. For these use cases, Scheduled Scaling lets you define exactly when your service should scale up or down, independent of real-time metrics.

With Scheduled Scaling, you configure a set of time-based rules directly in the ClickHouse Cloud console. Each rule specifies the days it is active, a start and end hour in UTC, and the settings to apply during that window — the number of replicas (horizontal), the minimum and maximum memory per replica (vertical), and whether the service is allowed to idle. While the window is active ClickHouse Cloud applies those settings, then reverts to your default scaling configuration when the window ends, so your service is sized appropriately before demand arrives rather than reacting after the fact.

This is distinct from metric-based autoscaling, which responds dynamically to CPU and memory pressure. Scheduled Scaling is deterministic: you know exactly when the scaling will happen and to what size. The two approaches are complementary — a service can have a baseline scaling schedule and still benefit from autoscaling within that window if workloads fluctuate unexpectedly.

Scheduled Scaling is currently available in **Beta**.

<h2 id="setting-up-a-scaling-schedule">
  Setting up a scaling schedule
</h2>

To configure a schedule, navigate to your service in the ClickHouse Cloud console and go to settings. From there, select **Schedule Override** and add a new rule.

<Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/avthXRFo-wpxxds8/images/cloud/features/autoscaling/scheduled-scaling-1.webp?fit=max&auto=format&n=avthXRFo-wpxxds8&q=85&s=3a9290c8080085378c3ad54f34c87f23" size="md" alt="The Scaling Schedules interface in the ClickHouse Cloud console, showing time-based scaling rules" border width="748" height="1606" data-path="images/cloud/features/autoscaling/scheduled-scaling-1.webp" />

<Image img="https://mintcdn.com/private-7c7dfe99-trino-dialect/avthXRFo-wpxxds8/images/cloud/features/autoscaling/scheduled-scaling-2.webp?fit=max&auto=format&n=avthXRFo-wpxxds8&q=85&s=d51794fc6c4ccf6b410454180de13231" size="md" alt="Configuring a scheduled scaling rule in the ClickHouse Cloud console" border width="938" height="534" data-path="images/cloud/features/autoscaling/scheduled-scaling-2.webp" />

Each rule requires:

* **Days active:** The days of the week the rule applies to
* **Start and end time:** The window during which the rule applies, given in **UTC** and on whole hours. A window whose end hour is earlier than its start hour runs overnight into the next day
* **Settings to apply:** The number of replicas, the minimum and maximum memory per replica, and the minimum idle time (or no idling) to use while the window is active

Multiple rules can be combined to form a full weekly schedule, as long as their windows do not overlap. For example, a single rule covering Monday to Friday from 06:00 to 20:00 UTC can hold your service at a larger size through the working day, with your default configuration applying outside that window.

<h2 id="use-cases">
  Use cases
</h2>

**Batch and ETL workloads:** Scale up before a nightly ingest job runs and scale back down once it completes, avoiding over-provisioning during idle daytime hours.

**Predictable traffic patterns:** Services with consistent peak hours (e.g. business-hours query traffic) can be pre-scaled to handle load before it arrives, rather than waiting for autoscaling to react.

**Weekend scale-down:** Reduce replica count or memory tier over weekends when demand is lower, then restore capacity before the Monday morning surge.

**Cost control:** For teams managing ClickHouse Cloud spend, scheduled scale-downs during known low-utilization periods can meaningfully reduce resource consumption without any manual intervention.

<Note>
  A scheduled scaling action and a concurrent autoscaling recommendation may interact — the schedule takes precedence at its trigger time.
</Note>

<h2 id="handling-bursty-workloads">
  Handling spikes in workload
</h2>

If you have an upcoming expected spike in your workload, you can use the
[ClickHouse Cloud API](/products/cloud/features/admin-features/api/api-overview) to
preemptively scale up your service to handle the spike and scale it down once
the demand subsides.

To understand the current CPU cores and memory in use for
each of your replicas, you can run the query below:

```sql theme={null}
SELECT *
FROM clusterAllReplicas('default', view(
    SELECT
        hostname() AS server,
        anyIf(value, metric = 'CGroupMaxCPU') AS cpu_cores,
        formatReadableSize(anyIf(value, metric = 'CGroupMemoryTotal')) AS memory
    FROM system.asynchronous_metrics
))
ORDER BY server ASC
SETTINGS skip_unavailable_shards = 1
```
