Azure Cosmos DB 无服务器(预览版)Azure Cosmos DB serverless (Preview)

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

Azure Cosmos DB 无服务器让你以一种基于消耗的方式使用 Azure Cosmos 帐户,在这种方式下,你只需为数据库操作所消耗的请求单位和数据所消耗的存储空间付费。Azure Cosmos DB serverless lets you use your Azure Cosmos account in a consumption-based fashion where you are only charged for the Request Units consumed by your database operations and the storage consumed by your data. 无服务器容器可以每秒处理数千个请求,无需你支付最低费用,也不需要你进行容量规划。Serverless containers can serve thousands of requests per second with no minimum charge and no capacity planning required.

重要

你是否有任何关于无服务器的反馈?Do you have any feedback about serverless? 我们想听一听!We want to hear it! 可以随意向 Azure Cosmos DB 无服务器团队发送消息:azurecosmosdbserverless@service.microsoft.comFeel free to drop a message to the Azure Cosmos DB serverless team: azurecosmosdbserverless@service.microsoft.com.

使用 Azure Cosmos DB 时,每个数据库操作都具有成本,以请求单位进行表示。When using Azure Cosmos DB, every database operation has a cost expressed in Request Units. 此成本的收费方式取决于你使用的 Azure Cosmos 帐户的类型:How you are charged for this cost depends on the type of Azure Cosmos account you are using:

  • 预配吞吐量模式下,你必须承诺在数据库和容器上预配的特定吞吐量(以每秒请求单位数进行表示)。In provisioned throughput mode, you have to commit to a certain amount of throughput (expressed in Request Units per second) that is provisioned on your databases and containers. 随后从每秒可用的请求单位数中扣除数据库操作的成本。The cost of your database operations is then deducted from the number of Request Units available every second. 在计费周期结束时,会针对你预配的吞吐量进行计费。At the end of your billing period, you get billed for the amount of throughput you have provisioned.
  • 在无服务器模式下,无需在 Azure Cosmos 帐户中创建容器时预配任何吞吐量。In serverless mode, you don't have to provision any throughput when creating containers in your Azure Cosmos account. 在计费周期结束时,会针对你的数据库操作已使用的请求单位数进行计费。At the end of your billing period, you get billed for the number of Request Units that were consumed by your database operations.

用例Use-cases

Azure Cosmos DB 无服务器最适合你预期会有“间歇性流量和不可预测的流量”且空闲时间较长的情况。Azure Cosmos DB serverless best fits scenarios where you expect intermittent and unpredictable traffic with long idle times. 因为在这种情况下预配容量不是必需的,而且可能会成本过高,所以在以下用例中应考虑使用 Azure Cosmos DB 无服务器:Because provisioning capacity in such situations isn't required and may be cost-prohibitive, Azure Cosmos DB serverless should be considered in the following use-cases:

  • Azure Cosmos DB 入门Getting started with Azure Cosmos DB
  • 运行的应用程序具有Running applications with
    • 突发性、难以预测的间歇性流量,或者bursty, intermittent traffic that is hard to forecast, or
    • 平均流量与峰值流量之比很低 (<10%)low (<10%) average-to-peak traffic ratio
  • 开发、测试新的应用程序,对新的应用程序进行原型设计,并在流量模式未知的生产环境中运行该应用程序Developing, testing, prototyping and running in production new applications where the traffic pattern is unknown
  • 与无服务器计算服务(如 Azure Functions)集成Integrating with serverless compute services like Azure Functions

有关如何选择最适合于用例的产品/服务的详细指南,请参阅如何在预配吞吐量与无服务器之间进行选择See the how to choose between provisioned throughput and serverless article for more guidance on how to choose the offer that best fits your use-case.

使用无服务器资源Using serverless resources

无服务器是一种新的 Azure Cosmos 帐户类型,这意味着在创建新帐户时,必须在预配吞吐量与无服务器之间进行选择 。Serverless is a new Azure Cosmos account type, which means that you have to choose between provisioned throughput and serverless when creating a new account. 必须创建新的无服务器帐户,才能开始使用无服务器。You must create a new serverless account to get started with serverless. 在预览版期间,创建新的无服务器帐户的唯一受支持方法是使用 Azure 门户During the preview release, the only supported way to create a new serverless account is by using the Azure portal. 当前不支持从/向无服务器模式迁移现有帐户。Migrating existing accounts to/from serverless mode is not currently supported.

任何在无服务器帐户中创建的容器都是无服务器容器。Any container that is created in a serverless account is a serverless container. 无服务器容器公开的功能与在预配吞吐量模式下创建的容器相同,因此可以通过完全相同的方式读取、写入和查询数据。Serverless containers expose the same capabilities as containers created in provisioned throughput mode, so you read, write and query your data the exact same way. 不过,无服务器帐户和容器还具有特定特征:However serverless accounts and containers also have specific characteristics:

重要

当无服务器正式发布时,其中一些限制可能会被删除,你的反馈将有助于我们做出决定!Some of these 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.

  • 无服务器帐户只能在单个 Azure 区域中运行。A serverless account can only run in a single Azure region. 创建无服务器帐户之后,不能向该帐户添加其他 Azure 区域。It is not possible to add additional Azure regions to a serverless account after you create it.
  • 不能对无服务器帐户启用 Synapse Link 预览功能It is not possible to enable the Synapse Link preview feature on a serverless account.
  • 无服务器容器不需要预配吞吐量,因此以下陈述适用于这种容器:Provisioning throughput is not required on serverless containers, so the following statements are applicable:
    • 创建无服务器容器时,不能传递任何吞吐量,否则会返回错误。You can't pass any throughput when creating a serverless container and doing so returns an error.
    • 不能读取或更新无服务器容器的吞吐量,否则会返回错误。You can't read or update the throughput on a serverless container and doing so returns an error.
    • 不能在无服务器帐户中创建共享吞吐量数据库,否则会返回错误。You can't create a shared throughput database in a serverless account and doing so returns an error.
  • 无服务器容器最多可存储 50 GB 的数据和索引。Serverless containers can store a maximum of 50 GB of data and indexes.

监视消耗量Monitoring your consumption

如果以前在预配吞吐量模式下使用了 Azure Cosmos DB,则会发现当流量证明预配容量不合理时,无服务器更加经济高效。If you have used Azure Cosmos DB in provisioned throughput mode before, you will find that serverless is more cost-effective when your traffic doesn't justify provisioned capacity. 权衡之处在于成本会不太容易预测,因为是基于数据库处理的请求数进行计费。The trade-off is that your costs will become less predictable because you are billed based on the number of requests your database has processed. 因此,请务必注意当前消耗量。Because of that, it's important to keep an eye on your current consumption.

当浏览帐户的“指标”窗格时,会在“概述”选项卡下找到名为“已消耗的请求单位”的图表 。此图表显示帐户已使用的请求单位数:When browsing the Metrics pane of your account, you will find a chart named Request Units consumed under the Overview tab. This chart shows how many Request Units your account has consumed:

显示已消耗的请求单位的图表

使用 Azure Monitor 时,可以找到相同的图表,如此处所述。You can find the same chart when using Azure Monitor, as described here. 请注意,Azure Monitor 允许设置警报,可用于在请求单位消耗量超过特定阈值时通知你。Note that Azure Monitor lets you setup alerts, which can be used to notify you when your Request Unit consumption has passed a certain threshold.

性能Performance

无服务器资源会产生与预配吞吐量资源提供的性能特征不同的特定性能特征。Serverless resources yield specific performance characteristics that are different from what provisioned throughput resources deliver. 在无服务器产品/服务公开发布之后,无服务器容器延迟的服务级别目标 (SLO) 对于点读取为 10 毫秒或更少,对于写入为 30 毫秒或更少。After the serverless offer becomes generally available, the latency of serverless containers will be covered by a Service Level Objective (SLO) of 10 milliseconds or less for point-reads and 30 milliseconds or less for writes. 点读取操作包含按其 ID 和分区键值提取单个项。A point-read operation consists in fetching a single item by its ID and partition key value.

后续步骤Next steps

可通过以下文章开始使用无服务器:Get started with serverless with the following articles: