您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何在预配吞吐量与无服务器之间进行选择How to choose between provisioned throughput and serverless

适用于: SQL API Cassandra API Gremlin API 表 API Azure Cosmos DB API for MongoDB

Azure Cosmos DB 提供了两种不同的容量模式:预配吞吐量无服务器Azure Cosmos DB is available in two different capacity modes: provisioned throughput and serverless. 在这两种模式下,你可以执行完全相同的数据库操作,但这些操作的收费方式截然不同。You can perform the exact same database operations in both modes, but the way you get billed for these operations is radically different. 以下视频说明了这些模式之间的核心差异,以及它们如何适应不同类型的工作负荷:The following video explains the core differences between these modes and how they fit different types of workloads:

详细比较Detailed comparison

条件Criteria 预配的吞吐量Provisioned throughput 无服务器Serverless
状态Status 正式发布Generally available 预览In preview
最适用于Best suited for 持续流量需要可预测性能的工作负荷Workloads with sustained traffic requiring predictable performance 具有间歇或无法预测的流量和低到高峰流量比的工作负荷Workloads with intermittent or unpredictable traffic and low average-to-peak traffic ratio
工作原理How it works 对于每个容器,你预配一定数量的吞吐量(以每秒请求单位数表示)。For each of your containers, you provision some amount of throughput expressed in Request Units per second. 每秒此数量的请求单位可用于你的数据库操作。Every second, this amount of Request Units is available for your database operations. 预配的吞吐量可以手动更新,也可以通过自动缩放自动调整。Provisioned throughput can be updated manually or adjusted automatically with autoscale. 你对容器运行数据库操作,无需预配任何容量。You run your database operations against your containers without having to provision any capacity.
地理分布Geo-distribution 可用(Azure 区域数不受限制)Available (unlimited number of Azure regions) 不可用(无服务器帐户只能在 1 个 Azure 区域中运行)Unavailable (serverless accounts can only run in 1 Azure region)
每个容器的最大存储Maximum storage per container 无限制Unlimited 50 GB50 GB
性能Performance SLA 涵盖的针对点读取和写入的延迟 < 10 毫秒< 10 ms latency for point-reads and writes covered by SLA SLA 涵盖的针对点读取的延迟 < 10 毫秒,针对写入的延迟 < 30 毫秒< 10 ms latency for point-reads and < 30 ms for writes covered by SLO
计费模式Billing model 对于预配的 RU/s,无论消耗了多少 RU,都按每小时计费。Billing is done on a per-hour basis for the RU/s provisioned, regardless of how many RUs were consumed. 根据数据库操作所消耗的 RU 数量,按小时收费。Billing is done on a per-hour basis for the amount of RUs consumed by your database operations.

重要

当无服务器正式发布时,一些无服务器限制可能会被解除或删除,你的反馈 将有助于我们做出决定!Some of the serverless limitations may be eased or removed when serverless becomes generally available and your feedback will help us decide! 请与我们联系,并告诉我们有关无服务器体验的详细信息:azurecosmosdbserverless@service.microsoft.comReach out and tell us more about your serverless experience: azurecosmosdbserverless@service.microsoft.com.

估计预期消耗量Estimating your expected consumption

在某些情况下,可能无法确定应当为给定的工作负荷选择预配吞吐量还是选择无服务器。In some situations, it may be unclear whether provisioned throughput or serverless should be chosen for a given workload. 若要帮助进行此决定,可以估算总体 预期消耗,这就是你可能会在一个月内消耗的每个 ru 的总数 (你可以使用 此处 显示的表的帮助来估算这一点) To help with this decision, you can estimate your overall expected consumption, that is what's the total number of RUs you may consume over a month (you can estimate this with the help of the table shown here)

示例 1:工作负荷应最多突发到 500 RU/s,并在一个月内总共使用20000000个 RU。Example 1: a workload is expected to burst to a maximum of 500 RU/s and consume a total of 20,000,000 RUs over a month.

  • 在预配吞吐量模式下,你可以预配 500 RU/秒的容器,每月成本为:$0.008 * 5 * 730 = $29.20In provisioned throughput mode, you would provision a container with 500 RU/s for a monthly cost of: $0.008 * 5 * 730 = $29.20
  • 在无服务器模式下,你需要为消耗的 RU 付费:$0.25 * 20 = $5.00In serverless mode, you would pay for the consumed RUs: $0.25 * 20 = $5.00

示例 2:工作负荷应最多突发到 500 RU/s,并在一个月内总共使用250000000个 RU。Example 2: a workload is expected to burst to a maximum of 500 RU/s and consume a total of 250,000,000 RUs over a month.

  • 在预配吞吐量模式下,你可以预配 500 RU/秒的容器,每月成本为:$0.008 * 5 * 730 = $29.20In provisioned throughput mode, you would provision a container with 500 RU/s for a monthly cost of: $0.008 * 5 * 730 = $29.20
  • 在无服务器模式下,你需要为消耗的 RU 付费:$0.25 * 250 = $62.50In serverless mode, you would pay for the consumed RUs: $0.25 * 250 = $62.50

(这些示例未考虑存储成本,这在两个模式之间是相同的)(these examples are not accounting for the storage cost, which is the same between the two modes)

备注

上面示例中所示的成本仅用于演示目的。The costs shown in the previous example are for demonstration purposes only. 有关最新定价信息,请参阅定价页See the pricing page for the latest pricing information.

后续步骤Next steps