在最短停機時間的情況下動態調整資料庫資源Dynamically scale database resources with minimal downtime

適用於: Azure SQL Database Azure SQL 受控執行個體

Azure SQL Database 和 SQL 受控執行個體可讓您以極短的 停機時間,以動態方式將更多資源新增至您的資料庫。不過,在一段時間內會有一段時間切換到資料庫的連線中斷,您可以使用重試邏輯來減輕這些問題。Azure SQL Database and SQL Managed Instance enable you to dynamically add more resources to your database with minimal downtime; however, there is a switch over period where connectivity is lost to the database for a short amount of time, which can be mitigated using retry logic.


當您的應用程式需求從幾個裝置和客戶成長到上百萬個裝置和客戶時,Azure SQL Database 和 SQL 受控執行個體在最短停機時間內即時調整規模。When demand for your app grows from a handful of devices and customers to millions, Azure SQL Database and SQL Managed Instance scale on the fly with minimal downtime. 擴充性是平臺即服務的最重要特性之一 (PaaS) ,可讓您在需要時,動態地將更多資源新增至您的服務。Scalability is one of the most important characteristics of platform as a service (PaaS) that enables you to dynamically add more resources to your service when needed. Azure SQL Database 可讓您輕鬆地變更配置給您資料庫的資源 (CPU 電源、記憶體、IO 輸送量和儲存體)。Azure SQL Database enables you to easily change resources (CPU power, memory, IO throughput, and storage) allocated to your databases.

避免效能問題的原因可能是您無法使用索引編製或查詢重寫方法固定之應用程式的使用量增加。You can mitigate performance issues due to increased usage of your application that cannot be fixed using indexing or query rewrite methods. 新增更多資源,可讓您在資料庫達到目前資源限制且需要更強大功能來處理內送工作負載時快速回應。Adding more resources enables you to quickly react when your database hits the current resource limits and needs more power to handle the incoming workload. Azure SQL Database 也可讓您相應減少不需要的資源,以降低成本。Azure SQL Database also enables you to scale-down the resources when they are not needed to lower the cost.

您不需要擔心購買硬體以及變更基礎結構。You don’t need to worry about purchasing hardware and changing underlying infrastructure. 使用滑杆可以輕鬆地透過 Azure 入口網站來調整資料庫。Scaling a database can be easily done via the Azure portal using a slider.


Azure SQL Database 提供以 DTU 為基礎的購買模型 和以 vCore 為基礎的購買模型,而 Azure SQL 受控執行個體只提供以 vCore 為基礎的購買模型Azure SQL Database offers the DTU-based purchasing model and the vCore-based purchasing model, while Azure SQL Managed Instance offers just the vCore-based purchasing model.

  • DTU 為基礎的購買模型 提供三個服務層級的計算、記憶體和 i/o 資源混合,以支援輕量的資料庫工作負載:基本、標準和 Premium。The DTU-based purchasing model offers a blend of compute, memory, and I/O resources in three service tiers to support lightweight to heavyweight database workloads: Basic, Standard, and Premium. 在各層內的效能層級分別提供這些資源的不同混用方式,而且您可以為其新增額外的儲存體資源。Performance levels within each tier provide a different mix of these resources, to which you can add additional storage resources.
  • 以虛擬核心為基礎的購買模型可讓您選擇虛擬核心的數目、記憶體數量,以及儲存體的數量和速度。The vCore-based purchasing model lets you choose the number of vCores, the amount or memory, and the amount and speed of storage. 此購買模型提供三個服務層級:一般用途、業務關鍵和超大規模。This purchasing model offers three service tiers: General Purpose, Business Critical, and Hyperscale.

您可以透過基本、標準或一般用途服務層級,以較低的每月成本在小型的單一資料庫上建置您的第一個應用程式,並在日後隨時以手動或程式設計方式將服務層級變更為進階或業務關鍵服務層級,以符合您的解決方案需求。You can build your first app on a small, single database at a low cost per month in the Basic, Standard, or General Purpose service tier and then change its service tier manually or programmatically at any time to the Premium or Business Critical service tier to meet the needs of your solution. 您的應用程式或客戶皆無須停機,即可調整效能。You can adjust performance without downtime to your app or to your customers. 動態延展性可讓您的資料庫以透明的方式回應快速變化的資源需求,並且讓您只需支付您所需的資源費用。Dynamic scalability enables your database to transparently respond to rapidly changing resource requirements and enables you to only pay for the resources that you need when you need them.


動態延展性與自動調整規模不同。Dynamic scalability is different from autoscale. 自動調整規模是指當服務根據準則自動調整時,動態調整可讓您以極短的停機時間進行手動調整。Autoscale is when a service scales automatically based on criteria, whereas dynamic scalability allows for manual scaling with a minimal downtime.

Azure SQL Database 中的單一資料庫支援手動動態調整,但不支援自動調整規模。Single databases in Azure SQL Database support manual dynamic scalability, but not autoscale. 若要獲得更多的 自動化 體驗,請考慮使用彈性集區,以根據個別的資料庫需求,讓資料庫共用集區中的資源。For a more automatic experience, consider using elastic pools, which allow databases to share resources in a pool based on individual database needs. 不過,有一些腳本可協助針對 Azure SQL Database 中的單一資料庫,自動調整規模。However, there are scripts that can help automate scalability for a single database in Azure SQL Database. 如需範例,請參閱使用 PowerShell 來監視和調整單一 SQL 資料庫的規模For an example, see Use PowerShell to monitor and scale a single SQL Database.

您可以在應用程式停機時間最短 (通常平均少於四秒) 的情況下,隨時變更 DTU 服務層級虛擬核心特性You can change DTU service tiers or vCore characteristics at any time with minimal downtime to your application (generally averaging under four seconds). 對於許多企業和應用程式而言,只要能夠建立資料庫,並依需求調高或調低的效能即可,尤其是當使用模式相當容易預測時更是如此。For many businesses and apps, being able to create databases and dial performance up or down on demand is enough, especially if usage patterns are relatively predictable. 但如果您有無法預測的使用模式,則管理成本和商務模式就會變得相當困難。But if you have unpredictable usage patterns, it can make it hard to manage costs and your business model. 針對此案例您可使用彈性集區,以在集區中的多個資料庫之間共用特定數量的 eDTU。For this scenario, you use an elastic pool with a certain number of eDTUs that are shared among multiple databases in the pool.

SQL Database 簡介:不同層級和等級的單一資料庫 DTU

Azure SQL Database 提供動態調整資料庫的功能:Azure SQL Database offers the ability to dynamically scale your databases:

  • 單一資料庫中,您可以使用 DTUvCore 模型定義將指派給每個資料庫的資源數量上限。With a single database, you can use either DTU or vCore models to define maximum amount of resources that will be assigned to each database.
  • 彈性集區可讓您定義集區中每個資料庫群組的資源上限。Elastic pools enable you to define maximum resource limit per group of databases in the pool.

Azure SQL 受控執行個體也可讓您進行調整:Azure SQL Managed Instance allows you to scale as well:

  • SQL 受控執行個體 使用 虛擬核心 模式,可讓您定義配置給您實例的 CPU 核心上限和儲存體上限。SQL Managed Instance uses vCores mode and enables you to define maximum CPU cores and maximum of storage allocated to your instance. 受控實例中的所有資料庫都會共用配置給實例的資源。All databases within the managed instance will share the resources allocated to the instance.

在任何一種情況下起始擴大或縮小動作將會重新開機 database engine 進程,並視需要將它移至不同的虛擬機器。Initiating scale up or scale down action in any of the flavors would restart database engine process and move it to a different virtual machine if needed. 將資料庫引擎進程移至新的虛擬機器是 線上 程式,您可以在程式進行時,繼續使用現有的 Azure SQL Database 服務。Moving database engine process to a new virtual machine is online process where you can continue using your existing Azure SQL Database service while the process is in progress. 目標資料庫引擎完全初始化並準備好處理查詢之後,連接將會 從來源切換至目標資料庫引擎Once the target database engine is fully initialized and ready to process the queries, the connections will be switched from source to target database engine.


當擴大/縮小程式完成時,您可以預期會有短暫的連接中斷。You can expect a short connection break when the scale up/scale down process is finished. 如果您已 針對標準暫時性錯誤執行重試邏輯,您將不會注意到容錯移轉。If you have implemented Retry logic for standard transient errors, you will not notice the failover.

替代調整方法Alternative scale methods

調整資源是改善資料庫效能的最簡單且最有效的方法,而不需要變更資料庫或應用程式程式碼。Scaling resources is the easiest and the most effective way to improve performance of your database without changing either the database or application code. 在某些情況下,即使是最高的服務層級、計算大小和效能優化,也可能無法以成功且符合成本效益的方式處理您的工作負載。In some cases, even the highest service tiers, compute sizes, and performance optimizations might not handle your workload in a successful and cost-effective way. 在此情況下,您可以使用下列額外選項來調整資料庫:In that case you have these additional options to scale your database:

  • 讀取向外 延展是您取得資料的一個唯讀複本的可用功能,您可以在其中執行要求的唯讀查詢,例如報表。Read scale-out is an available feature where you are getting one read-only replica of your data where you can execute demanding read-only queries such as reports. 唯讀複本會處理您的唯讀工作負載,而不會影響主資料庫上的資源使用方式。A read-only replica will handle your read-only workload without affecting resource usage on your primary database.
  • 資料庫分區是一組技術,可讓您將資料分割成數個資料庫,並分別調整它們。Database sharding is a set of techniques that enables you to split your data into several databases and scale them independently.

後續步驟Next steps