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

可随时对 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 帐户的总预配吞吐量等于:If 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:

  1. T x N RU/s,如果使用单个写入区域配置 Azure Cosmos 帐户。T x N RU/s if your Azure Cosmos account is configured with a single write region.

  2. T x (N+1) RU/s,如果使用能够处理写入的所有区域配置 Azure Cosmos 帐户。T x (N+1) RU/s if your Azure Cosmos account is configured with all regions capable of processing writes.

具有单个写入区域的预配吞吐量每 100 RU/秒的成本为 0.082 元/小时,具有多个可写区域的预配吞吐量每 100 RU/秒的成本为 0.102 元/小时。Provisioned throughput with single write region costs CNY 0.082/hour per 100 RU/s and provisioned throughput with multiple writable regions costs CNY 0.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-master 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 should support conflict resolution. 编写器的工作负载量会增加。The amount of workload for writers has increased. 从成本规划角度来看,若要在中国范围内执行 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/秒,这个月存储的数据为 1 TB。Consider you have a container in China North provisioned with throughput 10K RU/s and stores 1 TB of data this month. 假设你添加了三个区域 - 中国东部、中国北部 2 和中国东部 2,每个区域的存储和吞吐量相同,而你希望能够通过自己的多区域分布式应用将内容写入所有四个区域中的容器。Let's assume you add three regions - China East , China North 2, and China East 2, each with the same storage and throughput and you want the ability to write to the containers in all four regions from your multiple-regionally distributed app. 一个月的总月度帐单(假定为 31 天)如下所示:Your total monthly bill(assuming 31 days) in a month is as follows:

项目Item 使用情况(每月)Usage (monthly) 费率Rate 每月成本Monthly Cost
中国北部(多个写入区域)容器的吞吐量帐单Throughput bill for container in China North (multiple write regions) 10K RU/秒 * 24 * 3110K RU/s * 24 * 31 每小时每 100 RU/秒 0.102 元CNY 0.102 per 100 RU/s per hour 7,588.8 元CNY 7,588.8
3 个其他区域 - 中国东部、中国北部 2 和中国东部 2(多个写入区域)的吞吐量帐单Throughput bill for 3 additional regions - China East , China North 2, and China East 2(multiple write regions) (3 + 1) * 10K RU/秒 * 24 * 31(3 + 1) * 10K RU/s * 24 * 31 每小时每 100 RU/秒 0.102 元CNY 0.102 per 100 RU/s per hour 30,355.2 元CNY 30,355.2
中国北部容器的存储帐单Storage bill for container in China North 1 TB(或 1,024 GB)1 TB (or 1,024 GB) 2.576 元/GBCNY 2.576/GB 2637.83 元CNY 2637.83
3 个其他区域 - 中国东部、中国北部 2 和中国东部 2 的存储帐单Storage bill for 3 additional regions - China East , China North 2, and China East 2 3 * 1 TB(或 3,072 GB)3 * 1 TB (or 3,072 GB) 2.576 元/GBCNY 2.576/GB 7,913.47 元CNY 7,913.47
总计Total 48,192.3 元CNY 48,192.3

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

如果使用率效率低下(例如,一个或多个区域利用率不足或过度利用),则可以执行以下步骤以提高吞吐量利用率:If you have inefficient utilization, for example, one or more under-utilized or over-utilized regions, you can take the following steps to improve throughput utilization:

  1. 请确保首先优化写入区域中的预配吞吐量 (RU),然后通过使用来自读取区域等的更改源充分使用读取区域中的 RU。Make sure you optimize provisioned throughput (RUs) in the write region first, and then make the maximum use of the RUs in read regions by using change feed from the read-region etc.

  2. 多写入区域读取和写入可以跨与 Azure Cosmos 帐户关联的所有区域进行缩放。Multiple write regions reads and writes can be scaled across all regions associated with Azure Cosmos account.

  3. 监视区域中的活动,你可以按需添加和删除区域以缩放读取和写入吞吐量。Monitor the activity in your regions and you could add and remove regions on demand to scale your read and write throughput.

后续步骤Next steps

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