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

> ClickHouse Cloud 自动扩缩容概述

# 自动扩缩容

export const ScalePlanFeatureBadge = ({feature = '此功能', linking_verb_are = false}) => {
  return <div className="scalePlanFeatureContainer">
            <div className="scalePlanFeatureBadge">
                Scale 计划功能
            </div>
            <div>
                <p>{feature} {linking_verb_are ? '仅在' : '仅在'} Scale 和 Enterprise 计划中可用。要升级，请访问 Cloud Console 中的计划页面。</p>
            </div>
        </div>;
};

扩缩容是指调整可用资源以满足客户端需求的能力。Scale 和 Enterprise 层级的服务可通过编程方式调用 API 或在 UI 中更改设置来实现横向扩缩容。Scale 层级服务以及采用标准 `1:4` profile 的 Enterprise 层级服务还支持**垂直自动扩缩容**，以满足应用需求。

<ScalePlanFeatureBadge feature="垂直自动扩缩容" />

<Note>
  Scale 和 Enterprise 层级既支持单副本服务，也支持多副本服务。单副本 Scale 服务以及采用标准 `1:4` profile 的 Enterprise 服务支持自助式垂直自动扩缩容。采用自定义 profile 的 Enterprise 服务需要支持团队协助进行垂直调整。Scale 和 Enterprise 服务可横向扩缩容至多个副本。基础版层级服务仅有一个副本，规模固定，且不支持垂直或水平扩缩容。有关更多信息，请参阅[大型单副本服务](/zh/products/cloud/features/large-single-replica-services)。
</Note>

<h2 id="choosing-a-compute-option">
  选择计算方案
</h2>

请根据实际需求选择：是要调整现有 service 的容量、在专用 compute 上隔离某类 workload，还是为符合条件的查询临时追加 compute。

| 方案 | 作用 | 适用场景 |
| - | - | - |
| 对现有 service 进行扩缩容 | 垂直扩缩容调整 CPU 和内存；横向扩缩容调整副本数量，可手动进行，在受支持的情况下也可自动进行。 | 希望现有 service 随 workload 需求变化而扩容或缩容。 |
| [仓库](/zh/products/cloud/features/infrastructure/warehouses) | 创建拥有专用 compute 和端点、但共享同一份数据的独立 service。 | 需要为不同 workload 提供长期的 compute 隔离。 |
| [按需计算](/zh/products/cloud/features/infrastructure/on-demand-compute) | 通过现有的 service 和端点，从托管 pool 中临时分配 worker。 | 符合条件的 `SELECT` 查询需要额外 compute，但不希望调整 service 规格。 |

<Note>
  扩缩容的支持情况因 service 层级和 profile 而异。[横向自动扩缩容](/zh/products/cloud/features/autoscaling/horizontal-autoscaling)目前处于私有预览阶段。按需计算同样处于私有预览阶段，且仅支持符合条件的 `SELECT` 查询。
</Note>

<h2 id="how-scaling-works-in-clickhouse-cloud">
  ClickHouse Cloud 中扩缩容的工作方式
</h2>

ClickHouse Cloud 为 Scale 和 Enterprise 层级服务提供手动水平扩缩容。Scale 层级服务还支持垂直自动扩缩容；Enterprise 层级服务是否支持垂直自动扩缩容取决于 profile，如下所述。[横向自动扩缩容](/zh/products/cloud/features/autoscaling/horizontal-autoscaling)已在私有预览中面向 Scale 和 Enterprise 层级服务提供。

对于 Enterprise 层级服务，扩缩容规则如下：

* **水平扩缩容**：Enterprise 层级的所有标准和自定义 profile 均支持手动水平扩缩容。
* **垂直扩缩容**：
  * 标准 `1:4` profile 支持垂直自动扩缩容。
  * 自定义 profile (`highMemory` 和 `highCPU`) 不支持垂直自动扩缩容或手动垂直扩缩容。不过，可通过联系支持团队来对这些服务执行垂直扩缩容。

<Note>
  ClickHouse Cloud 中的扩缩容采用我们称为 ["Make Before Break" (MBB)](/zh/products/cloud/features/autoscaling/make-before-break) 的方式。
  该方式会先添加一个或多个新规格的副本，再移除旧副本，从而避免在扩缩容过程中出现容量损失。
  通过消除移除现有副本与添加新副本之间的空窗期，MBB 使扩缩容过程更平滑、干扰更小。
  这种方式在扩容场景下尤其有利：当资源利用率较高而触发对额外容量的需求时，过早移除副本只会进一步加剧资源压力。
  作为这种方式的一部分，我们最多会等待一小时，让旧副本上正在运行的查询完成后再将其移除。
  这样既能兼顾现有查询顺利完成，也能避免旧副本保留过久。
</Note>

<h2 id="learn-more">
  了解更多
</h2>

* [垂直自动扩缩容](/zh/products/cloud/features/autoscaling/vertical) — 根据使用情况自动调整 CPU 和内存资源
* [横向自动扩缩容](/zh/products/cloud/features/autoscaling/horizontal-autoscaling) — 根据工作负载需求自动调整副本数量
* [水平扩缩容](/zh/products/cloud/features/autoscaling/horizontal) — 通过 API 或 UI 手动调整副本数量
* [Make Before Break (MBB)](/zh/products/cloud/features/autoscaling/make-before-break) — 了解 ClickHouse Cloud 如何执行无缝扩缩容
* [自动闲置](/zh/products/cloud/features/autoscaling/idling) — 通过自动暂停服务节省成本
* [扩缩容建议](/zh/products/cloud/features/autoscaling/scaling-recommendations) — 了解扩缩容建议
* [定时扩缩容](/zh/products/cloud/features/autoscaling/scheduled-scaling) — 了解定时扩缩容功能：可精确定义服务何时扩容或缩容，而不受实时指标影响
* [大型单副本服务](/zh/products/cloud/features/large-single-replica-services) — Scale 和 Enterprise 层级上单副本服务的垂直扩缩容
