在 Azure SQL 数据库中缩放弹性池资源Scale elastic pool resources in Azure SQL Database

本文介绍如何在 Azure SQL 数据库中缩放适用于弹性池和共用数据库的计算和存储资源。This article describes how to scale the compute and storage resources available for elastic pools and pooled databases in Azure SQL Database.

更改计算资源(vCore 或 DTU)Change compute resources (vCores or DTUs)

最初选择 vCore 或 eDTU 数量后,可以使用 Azure 门户PowerShellAzure CLIREST API,根据实际体验动态扩展或缩减弹性池。After initially picking the number of vCores or eDTUs, you can scale an elastic pool up or down dynamically based on actual experience using the Azure portal, PowerShell, the Azure CLI, or the REST API.

更改服务层级或重新缩放计算大小的影响Impact of changing service tier or rescaling compute size

更改弹性池的服务层级或计算大小遵循适用于单一数据库的类似模式,该过程主要涉及到由服务执行的以下步骤:Changing the service tier or compute size of an elastic pool follows a similar pattern as for single databases and mainly involves the service performing the following steps:

  1. 为弹性池创建新的计算实例Create new compute instance for the elastic pool

    使用请求的服务层级和计算大小为弹性池创建新的计算实例。A new compute instance for the elastic pool is created with the requested service tier and compute size. 更改后,对于服务层级和计算大小的某些组合,必须在新的计算实例中创建每个数据库的副本,此过程涉及到数据复制,可能会对总体延迟造成很大的影响。For some combinations of service tier and compute size changes, a replica of each database must be created in the new compute instance which involves copying data and can strongly influence the overall latency. 无论如何,在执行此步骤期间,数据库会保持联机,并且连接会继续定向到原始计算实例中的数据库。Regardless, the databases remain online during this step, and connections continue to be directed to the databases in the original compute instance.

  2. 将连接路由切换到新的计算实例Switch routing of connections to new compute instance

    将删除与原始计算实例中的数据库建立的现有连接。Existing connections to the databases in the original compute instance are dropped. 将与新计算实例中的数据库建立任何新的连接。Any new connections are established to the databases in the new compute instance. 更改后,对于服务层级和计算大小的某些组合,在切换期间会分离再重新附加数据库文件。For some combinations of service tier and compute size changes, database files are detached and reattached during the switch. 无论如何,切换操作都可能会导致服务出现短暂的中断,此时,数据库一般会出现 30 秒以下的不可用情况(通常只有几秒钟)。Regardless, the switch can result in a brief service interruption when databases are unavailable generally for less than 30 seconds and often for only a few seconds. 如果连接断开时有长时间运行的事务正在运行,则此步骤的持续时间可能会变长,以便恢复中止的事务。If there are long running transactions running when connections are dropped, the duration of this step may take longer in order to recover aborted transactions. 加速的数据库恢复可以降低中止长期运行的事务的影响。Accelerated Database Recovery can reduce the impact from aborting long running transactions.

Important

执行工作流中的任何步骤期间都不会丢失数据。No data is lost during any step in the workflow.

更改服务层级或重新缩放计算大小所造成的延迟Latency of changing service tier or rescaling compute size

可根据如下所述,将更改服务层级或者重新缩放单一数据库或弹性池的计算大小所造成的估计延迟参数化:The estimated latency to change the service tier or rescale the compute size of a single database or elastic pool is parameterized as follows:

服务层Service tier 基本单一数据库,Basic single database,
标准 (S0-S1)Standard (S0-S1)
基本弹性池,Basic elastic pool,
标准 (S2-S12),Standard (S2-S12),
超大规模,Hyperscale,
常规用途单一数据库或弹性池General Purpose single database or elastic pool
高级或业务关键型单一数据库或弹性池Premium or Business Critical single database or elastic pool
基本单一数据库,
标准 (S0-S1)
Basic single database,
Standard (S0-S1)
•  延迟时间较为恒定,与已用空间无关•  Constant time latency independent of space used
•  通常小于 5 分钟•  Typically, less than 5 minutes
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
基本弹性池、
标准 (S2-S12)、
超大规模、
常规用途单一数据库或弹性池
Basic elastic pool,
Standard (S2-S12),
Hyperscale,
General Purpose single database or elastic pool
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
•  延迟时间较为恒定,与已用空间无关•  Constant time latency independent of space used
•  通常小于 5 分钟•  Typically, less than 5 minutes
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
高级或业务关键型单一数据库或弹性池Premium or Business Critical single database or elastic pool •  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used
•  由于数据复制,延迟与已用数据库空间成比例•  Latency proportional to database space used due to data copying
•  对于每 GB 的已用空间,延迟通常小于 1 分钟•  Typically, less than 1 minute per GB of space used

Note

  • 如果更改服务层或者重新缩放弹性池的计算大小,则应使用池中所有数据库的已用空间之和来计算估计值。In the case of changing the service tier or rescaling compute for an elastic pool, the summation of space used across all databases in the pool should be used to calculate the estimate.
  • 如果向/从弹性池移动数据库,则只有数据库使用的空间会影响延迟,弹性池使用的空间不会影响延迟。In the case of moving a database to/from an elastic pool, only the space used by the database impacts the latency, not the space used by the elastic pool.

Tip

若要监视正在进行的操作,请参阅:使用 SQL REST API 管理操作使用 CLI 管理操作使用 T-SQL 监视操作及以下两个 PowerShell 命令:Get-AzSqlDatabaseActivityStop-AzSqlDatabaseActivityTo monitor in-progress operations, see: Manage operations using the SQL REST API, Manage operations using CLI, Monitor operations using T-SQL and these two PowerShell commands: Get-AzSqlDatabaseActivity and Stop-AzSqlDatabaseActivity.

更改服务层级或重新缩放计算大小时的其他注意事项Additional considerations when changing service tier or rescaling compute size

  • 减少弹性池的 vCore 或 eDTU 时,该池使用的空间必须小于目标服务层和池 eDTU 所允许的最大大小。When downsizing vCores or eDTUs for an elastic pool, the pool used space must be smaller than the maximum allowed size of the target service tier and pool eDTUs.
  • 当重新缩放弹性池的 eDTU 时,如果 (1) 目标池支持池的存储上限,(2) 存储上限超过了目标池附送的存储量,将产生额外存储费用。When rescaling eDTUs for an elastic pool, an extra storage cost applies if (1) the storage max size of the pool is supported by the target pool, and (2) the storage max size exceeds the included storage amount of the target pool. 例如,如果最大大小为 100 GB 的 100 eDTU 标准池缩小为 50 eDTU 标准池,那么将产生额外存储费用,因为目标池支持的最大大小为 100 GB,其附送的存储量仅为 50 GB。For example, if a 100 eDTU Standard pool with a max size of 100 GB is downsized to a 50 eDTU Standard pool, then an extra storage cost applies since target pool supports a max size of 100 GB and its included storage amount is only 50 GB. 因此,额外的存储量为 100 GB - 50 GB = 50 GB。So, the extra storage amount is 100 GB - 50 GB = 50 GB. 有关额外存储定价的信息,请参阅 SQL 数据库定价For pricing of extra storage, see SQL Database pricing. 如果实际使用的空间量小于附送的存储量,只要将数据库最大大小减少到附送的量,就能避免此项额外费用。If the actual amount of space used is less than the included storage amount, then this extra cost can be avoided by reducing the database max size to the included amount.

重新缩放期间的计费Billing during rescaling

将根据使用最高服务层级的数据库存在的每个小时 + 在该小时适用的计算大小进行计费,无论使用方式或数据库处于活动状态是否少于一小时。You are billed for each hour a database exists using the highest service tier + compute size that applied during that hour, regardless of usage or whether the database was active for less than an hour. 例如,如果创建了单一数据库,并在五分钟后将其删除,则将按该数据库存在一小时收费。For example, if you create a single database and delete it five minutes later your bill reflects a charge for one database hour.

更改弹性池存储大小Change elastic pool storage size

Important

在某些情况下,可能需要收缩数据库来回收未使用的空间。Under some circumstances, you may need to shrink a database to reclaim unused space. 有关详细信息,请参阅管理 Azure SQL 数据库中的文件空间For more information, see Manage file space in Azure SQL Database.

基于 vCore 的购买模型vCore-based purchasing model

  • 可将存储预配到最大大小限制。Storage can be provisioned up to the max size limit:

    • 对于“标准”或“常规用途”服务层级中的存储,按 10 GB 增量增减大小For storage in the standard or general purpose service tiers, increase or decrease size in 10-GB increments
    • 对于“高级”或“业务关键”服务层级中的存储,按 250 GB 增量增减大小For storage in the premium or business critical service tiers, increase or decrease size in 250-GB increments
  • 可以通过增大或减小其最大大小来预配弹性池的存储空间。Storage for an elastic pool can be provisioned by increasing or decreasing its max size.

  • 弹性池的存储价格等于存储量乘以服务层级的存储单价。The price of storage for an elastic pool is the storage amount multiplied by the storage unit price of the service tier. 有关额外存储价格的详细信息,请参阅 SQL 数据库定价For details on the price of extra storage, see SQL Database pricing.

Important

在某些情况下,可能需要收缩数据库来回收未使用的空间。Under some circumstances, you may need to shrink a database to reclaim unused space. 有关详细信息,请参阅管理 Azure SQL 数据库中的文件空间For more information, see Manage file space in Azure SQL Database.

基于 DTU 的购买模型DTU-based purchasing model

  • 弹性池的 eDTU 价格附送了一定容量的存储,无需额外费用。The eDTU price for an elastic pool includes a certain amount of storage at no additional cost. 超出附送的量后,可花费额外的费用预配额外的存储,但不能超过存储上限,不超过 1 TB 时,以 250 GB 为增量进行预配,超出 1 TB 时,以 256 GB 为增量进行预配。Extra storage beyond the included amount can be provisioned for an additional cost up to the max size limit in increments of 250 GB up to 1 TB, and then in increments of 256 GB beyond 1 TB. 有关附送存储量和大小上限,请参阅弹性池:存储大小和计算大小For included storage amounts and max size limits, see Elastic pool: storage sizes and compute sizes.
  • 可通过 Azure 门户PowerShellAzure CLIREST API 为弹性池增加大小上限,以预配额外存储。Extra storage for an elastic pool can be provisioned by increasing its max size using the Azure portal, PowerShell, the Azure CLI, or the REST API.
  • 弹性池的额外存储价格等于额外存储量乘以服务层级的额外存储单价。The price of extra storage for an elastic pool is the extra storage amount multiplied by the extra storage unit price of the service tier. 有关额外存储价格的详细信息,请参阅 SQL 数据库定价For details on the price of extra storage, see SQL Database pricing.

Important

在某些情况下,可能需要收缩数据库来回收未使用的空间。Under some circumstances, you may need to shrink a database to reclaim unused space. 有关详细信息,请参阅管理 Azure SQL 数据库中的文件空间For more information, see Manage file space in Azure SQL Database.

后续步骤Next steps

有关总体资源限制,请参阅 SQL 数据库基于 vCore 的资源限制 - 弹性池SQL 数据库基于 DTU 的资源限制 - 弹性池For overall resource limits, see SQL Database vCore-based resource limits - elastic pools and SQL Database DTU-based resource limits - elastic pools.