Understanding partitioning schemes

To meet the performance needs of your application, Azure Cosmos DB uses partitioning to scale individual containers in a database. Cosmos DB partitions in a way that the items are divided into distinct subsets called logical partitions. These are formed based on the value of the partition key that is added to each item in the container. All of the items that are in a logical partition have the same partition key. Each item in a container has an item ID (which is unique within the logical partition). To create the item's index, the partition key and the item ID are combined. This uniquely identifies the item.

If you look at our sample application from the previous section, you will see that the partition key and item ID are combined.

Besides logical partitions, Azure Cosmos DB also has physical partitions:

  • Logical partitions: A set of items that have the same partition key are called a logical partition. For instance, if you have a container that stores items that all contain a Product property, you can use this as the partition key. Logical partitions are then formed by groups that have the same values, such as Books,  Videos, Movies, and Music. Containers are the fundamental units of scalability in Azure Cosmos DB. Data that is added to the container, together with the throughput (see next section) that is provisioned on the container, are automatically (horizontally) partitioned across a set of logical partitions based on the partition key.
  • Physical partitions: Internally, one or more logical partitions are mapped to a physical partition. This partition consists of a set of replicas, also called a replica set. Each replica set is hosting an instance of the Azure Cosmos database engine. It makes the data that is stored inside the physical partition highly available, consistent, and durable. The maximum amount of request units (RUs) and storage are supported by the physical partition.

The following chart shows how logical partitions are mapped to physical partitions that are distributed globally over multiple regions:

Partitioning in Azure Cosmos DB

In the next section, we are going to cover how to set the appropriate consistency level for operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset