Azure CosmosDB number of physical partition

sakuraime 2,341 Reputation points
2021-09-13T12:47:32.82+00:00

how CosmosDB determine the number of phyiscal parition will need to store a container ?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2021-09-13T17:18:54.39+00:00

    Hi @sakuraime Thank you for posting your question on Microsoft Q&A. The number of physical partitions in your container depends on the following:

    The number of throughput provisioned (each individual physical partition can provide a throughput of up to 10,000 request units per second). The 10,000 RU/s limit for physical partitions implies that logical partitions also have a 10,000 RU/s limit, as each logical partition is only mapped to one physical partition.

    The total data storage (each individual physical partition can store up to 50GB data).
    The articles below explain this in more details .
    https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning-overview#physical-partitions
    https://learn.microsoft.com/en-us/azure/cosmos-db/scaling-provisioned-throughput-best-practices#prerequisites

    Hope that helps

    Regards,
    Oury


  2. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2021-09-16T17:09:55.3+00:00

    @sakuraime you can take a look at this new doc below, which explains how many physical partitions you'll start with based on the RU/s that you set.
    https://learn.microsoft.com/en-us/azure/cosmos-db/scaling-provisioned-throughput-best-practices#step-3-calculate-the-number-of-rus-to-start-with

    Calculate the number of physical partitions you'll need
    Number of physical partitions = Total data size in GB / Target data per physical partition in GB

    Each physical partition can hold a maximum of 50 GB of storage (30 GB for Cassandra API). The value you should choose for the Target data per physical partition in GB depends on how fully packed you want the physical partitions to be and how much you expect storage to grow post-migration.

    For example, if you anticipate that storage will continue to grow, you may choose to set the value to 30 GB. Assuming you've chosen a good partition key that evenly distributes storage, each partition will be ~60% full (30 GB out of 50 GB). As future data is written, it can be stored on the existing set of physical partitions, without requiring the service to immediately add more physical partitions.

    In contrast, if you believe that storage will not grow significantly post-migration, you may choose to set the value higher, for example 45 GB. This means each partition will be ~90% full (45 GB out of 50 GB). This minimizes the number of physical partitions your data is spread across, which means each physical partition can get a larger fraction of the total provisioned RU/s.

    Hope that help

    Regards,
    Oury


  3. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2021-09-29T21:38:42.863+00:00

    Hi @sakuraime Sorry for the delay in my response.
    I initially I create a container with RU 50000, will it split to 5 physical partition already ? (even there are no data)
    If you initially created with 50k RUs, you would have 7 physical partitions. (50k/6k) and then rounded up. If you scaled up to 50k after creation, then yes correct 5 physical partitions.
    If I filled up some data , like 10GB , and then some day I would like to save cost and shrink the RU back to 30000
    Cosmos DB doesn’t currently supporting “merging” partitions back together. Splits aren’t reversible.

    Hope that helps

    Regards,
    Oury


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.