Mastering Azure Cosmos DB Consistency and Partitioning

Crack the two most-tested Cosmos DB exam topics: choosing the right partition key to avoid hot partitions, and selecting from five consistency levels for your real-world scenario.

# Mastering Azure Cosmos DB Consistency and Partitioning *This article is Part 2, Chapter 2.1 of the **AZ-204 Exam Refresher** series. We enter the data storage domain with Cosmos DB's two most exam-heavy concepts: partition key design and the five consistency levels.* --- ## Introduction Azure Cosmos DB is Microsoft's globally distributed, multi-model database — and it consistently shows up as one of the most tested topics on AZ-204. The reason is that Cosmos DB requires you to make architectural decisions up front (partition key, consistency level) that are difficult to change later, which makes them rich material for scenario-based exam questions. Think of Cosmos DB like a distributed filing cabinet. The **partition key** determines which drawer your document goes into. Choose wisely and reads and writes are fast. Choose poorly and everyone crowds around the same drawer — a "hot partition." --- ## Core Concepts ### Understanding Partitioning Cosmos DB stores data across physical partitions — independent nodes that each handle a subset of your data. The **logical partition** is determined by the partition key value. Multiple logical partitions may share a single physical partition, but a logical partition never spans physical partitions. **Each logical partition has a hard limit of 20 GB.** The partition key is set at container creation and **cannot be changed**. This is why partition key design is critical. #### Choosing a Good Partition Key A good partition k