# Containers & Partitions

## Azure Cosmos DB containers and partitions <a href="#azure-cosmos-db-containers" id="azure-cosmos-db-containers"></a>

An Azure Cosmos DB container is where data is stored. Unlike most relational databases which scale up with larger VM sizes, Azure Cosmos DB **scales out.**&#x20;

### Partitions

* Data is stored on one or more servers, called **partitions**.&#x20;
* To increase throughput or storage, more partitions are added.&#x20;
* This relationship provides a virtually an unlimited amount of throughput and storage for a container.&#x20;

<figure><img src="https://3317779635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKUWTpo9dP9oeKDkuqaGE%2Fuploads%2FaGpxmcJPrQ27JKYR1dim%2Fimage.png?alt=media&#x26;token=1f39a884-5bb2-4259-a20a-19a90f114b20" alt=""><figcaption></figcaption></figure>

### Partition key

* When a container is created, you need to supply a partition key or a shard key.&#x20;
* The partition key is a **property you select from your items** to help Azure Cosmos DB distribute the data efficiently across partitions.&#x20;
* The value of this property is then used to **route data** to the appropriate partition to be written, updated, or deleted.&#x20;
* The partition key can also be used in the **WHERE clause** in queries for efficient data retrieval.
* Logical partition can store up to **20GB** of data.

<figure><img src="https://3317779635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKUWTpo9dP9oeKDkuqaGE%2Fuploads%2FqG6zTO1jVbSAPcLHq7W0%2Fimage.png?alt=media&#x26;token=f7f37211-17d1-43c0-9678-0ccdd3e39843" alt=""><figcaption></figcaption></figure>

### Schema agnostic

Containers are schema agnostic. Items within a container can have arbitrary schemas or different entities so long as they share the same partition key. For example, an item that represents a customer and one or more items representing all their orders, can be placed in the *same container!*
