Optimize multi-region cost in Azure Cosmos DB
APPLIES TO: SQL API Cassandra API Gremlin API Table API Azure Cosmos DB API for MongoDB
You can add and remove regions to your Azure Cosmos account at any time. The throughput that you configure for various Azure Cosmos databases and containers is reserved in each region associated with your account. 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
T x N RU/s.
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. To learn more, see Azure Cosmos DB Pricing page.
Costs for multiple write regions
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. From 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. 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.
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. Your new total monthly bill (assuming 744 hours in a month) will be as follows:
|Item||Usage (monthly)||Rate||Monthly Cost|
|Throughput bill for container in China North (single write region)||10K RU/s * 24 hours * 31 days||CNY0.051 per 100 RU/s per hour||CNY 3,794.4|
|Throughput bill for container in 2 regions - China North & China East (multiple write regions)||2 * 10K RU/s * 24 hours * 31 days||CNY0.102 per 100 RU/s per hour||CNY 15,177.6|
|Storage bill for container in China North||0.5 TB (or 512 GB)||CNY 2.576/GB||CNY 1318.92|
|Storage bill for container in 2 regions - China North & China East||2 * 0.5 TB (or 1,024 GB)||CNY 2.576/GB||CNY 2637.83|
Improve throughput utilization on a per region-basis
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. 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 you can proceed to learn more about cost optimization in Azure Cosmos DB with the following articles:
- Learn more about Optimizing for development and testing
- Learn more about Understanding your Azure Cosmos DB bill
- Learn more about Optimizing throughput cost
- Learn more about Optimizing storage cost
- Learn more about Optimizing the cost of reads and writes
- Learn more about Optimizing the cost of queries
- Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
- If all you know is the number of vcores and servers in your existing database cluster, read about estimating request units using vCores or vCPUs
- If you know typical request rates for your current database workload, read about estimating request units using Azure Cosmos DB capacity planner