在 Azure Cosmos DB 中优化多区域成本Optimize multi-region cost in Azure Cosmos DB

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

可随时对 Azure Cosmos 帐户添加或删除区域。You can add and remove regions to your Azure Cosmos account at any time. 在与帐户关联的每个区域中会保留为各种 Azure Cosmos 数据库和容器配置的吞吐量。The throughput that you configure for various Azure Cosmos databases and containers is reserved in each region associated with your account. 如果每小时的预配吞吐量(即,跨所有数据库和容器为 Azure Cosmos 帐户配置的 RU/秒总和)为 T,并且与数据库帐户关联的 Azure 区域数是 N,则对于给定小时,Cosmos 帐户的总预配吞吐量等于 T x N RU/sIf the throughput provisioned per hour, that is the sum of RU/s configured across all the databases and containers for your Azure Cosmos account is T and the number of Azure regions associated with your database account is N, then the total provisioned throughput for your Cosmos account, for a given hour is equal to T x N RU/s.

具有单个写入区域的预配吞吐量每 100 RU/秒的成本为 0.051 元/小时,具有多个可写区域的预配吞吐量每 100 RU/秒的成本为 0.102 元/小时。Provisioned throughput with single write region costs CNY0.051/hour per 100 RU/s and provisioned throughput with multiple writable regions costs CNY0.102/per hour per 100 RU/s. 若要了解详细信息,请参阅 Azure Cosmos DB 定价页To learn more, see Azure Cosmos DB Pricing page.

多个写入区域的成本Costs for multiple write regions

在多区域写入系统中,可用于写入操作的净 RU 会增加 N 倍,其中 N 是写入区域数。In a multi-region writes system, the net available RUs for write operations increases N times where N is the number of write regions. 与单区域写入不同,每个区域现在都可写并且支持冲突解决。Unlike single region writes, every region is now writable and supports conflict resolution. 从成本规划角度来看,若要在中国范围内执行 M RU/秒的写入,需要在容器或数据库级别预配 M RUsFrom the cost planning point of view, to perform M RU/s worth of writes around China, you will need to provision M RUs at a container or database level. 随后可以添加任意多个区域并将它们用于写入以在中国范围内执行 M RU 写入。You can then add as many regions as you would like and use them for writes to perform M RU worth of around China writes.

示例Example

假设在中国北部配置了一个用于单区域写入的容器,该容器预配的吞吐量为 10K RU/秒,这个月存储的数据为 0.5 TB。Consider that you have a container in China North configured for single-region writes, provisioned with throughput of 10K RU/s, storing 0.5 TB of data this month. 假设你添加了一个具有相同存储和吞吐量的区域“中国东部”,并且你希望能够从你的应用写入到这两个区域中的容器。Let's assume you add a region, China East, with the same storage and throughput and you want the ability to write to the containers in both the regions from your app. 新的月度总账单(假设每月 744 个小时)将如下所示:Your new total monthly bill (assuming 744 hours in a month) will be as follows:

ItemItem 使用情况(每月)Usage (monthly) 费率Rate 每月成本Monthly Cost
中国北部(单个写入区域)容器的吞吐量账单Throughput bill for container in China North (single write region) 10K RU/秒 * 24 小时 * 31 天10K RU/s * 24 hours * 31 days 每小时每 100 RU/秒 0.051 元CNY0.051 per 100 RU/s per hour 3,794.4 元CNY 3,794.4
中国北部和中国东部这 2 个区域(多个写入区域)中容器的吞吐量帐单Throughput bill for container in 2 regions - China North & China East (multiple write regions) 2 * 10K RU/秒 * 24 小时 * 31 天2 * 10K RU/s * 24 hours * 31 days 每小时每 100 RU/秒 0.102 元CNY0.102 per 100 RU/s per hour 15,177.6 元CNY 15,177.6
中国北部容器的存储帐单Storage bill for container in China North 0.5 TB(或 512 GB)0.5 TB (or 512 GB) 2.576 元/GBCNY 2.576/GB 1318.92 元CNY 1318.92
2 个区域(中国北部和中国东部)的存储帐单Storage bill for 2 regions - China North & China East 2 * 0.5 TB(或 1,024 GB)2 * 0.5 TB (or 1,024 GB) 2.576 元/GBCNY 2.576/GB 2637.83 元CNY 2637.83

按每个区域提高吞吐量利用率Improve throughput utilization on a per region-basis

如果利用率不足,例如有一个或多个未充分利用的读取区域,则可以采取措施来最大限度地利用读取区域中的 RU,具体方式是从读取区域使用“更改源”或将其移动到另一个次要区域(如果已过度利用)。If you have inefficient utilization, for example, one or more under-utilized read regions you can take steps to make the maximum use of the RUs in read regions by using change feed from the read-region or move it to another secondary if over-utilized. 你将需要确保先在写入区域中优化预配吞吐量 (RU)。You will need to ensure you optimize provisioned throughput (RUs) in the write region first. 除非查询非常大,否则写入操作的开销就会大于读取操作的开销,因此维持平稳的利用率可能会很困难。Writes cost more than reads unless very large queries so maintaining even utilization can be challenging. 总的来说,监视区域中已消耗的吞吐量,并根据需要添加或删除区域以缩放读取和写入吞吐量,确保了解对同一区域中部署的任何应用的延迟造成的影响。Overall, monitor the consumed throughput in your regions and add or remove regions on demand to scale your read and write throughput, making to sure understand the impact to latency for any apps that are deployed in the same region.

后续步骤Next steps

接下来,可通过以下文章详细了解 Azure Cosmos DB 中的成本优化:Next you can proceed to learn more about cost optimization in Azure Cosmos DB with the following articles: