What is Azure Cosmos DB? Choose partitioning, consistency, and throughput for your workload
Azure Cosmos DB is a managed NoSQL database service that can replicate data across regions. Its central design choices are the partition key that distributes data, the consistency level that balances read freshness against latency, and the capacity model that measures database work in Request Units (RUs). These choices can be difficult to reverse, so model real query patterns and traffic before choosing a product API or relying on a simple benchmark.
What is Azure Cosmos DB? Choose partitioning, consistency, and throughput for your workload
Azure Cosmos DB is a managed NoSQL database service that can replicate data across regions. Its central design choices are the partition key that distributes data, the consistency level that balances read freshness against latency, and the capacity model that measures database work in Request Units (RUs). These choices can be difficult to reverse, so model real query patterns and traffic before choosing a product API or relying on a simple benchmark.
How do accounts, databases, containers, and items fit together?
An account is the top-level resource for API, regional replication, default consistency, and network settings. A database is a management unit within the account. A container stores items and is the unit that scales storage and throughput. An item is one record in a container. Depending on the API, these may be called NoSQL documents, MongoDB collections, or Cassandra tables. The names and interfaces vary, but the resource hierarchy and partition design still matter.
API compatibility can let a team reuse familiar tools and drivers, but it does not mean every feature or behavior is identical to the source database. Check the chosen API’s supported features, SDKs, and limits before committing.
Why does the partition key matter, and how should you choose it?
When creating a container, you choose a property path that determines how items are distributed. Items with the same key value belong to one logical partition. Cosmos DB hashes key values and maps logical partitions onto internal physical partitions, which the service manages and can split as data grows. Application designers choose the partition key; they do not manage physical placement directly.
A useful partition key has many distinct values (high cardinality), spreads data and RU consumption across those values, and matches common query filters. For example, if customer order history is the main access pattern, customerId may be a candidate. But a very active customer can create a hot partition and may approach the storage or throughput limits of a logical partition. A random item ID can spread writes well, yet searches by customer may need cross-partition queries.
A partition key value cannot be changed in place after an item is created. Changing the design requires a new container, copying and validating the data, and switching the application. Evaluate key distribution together with actual queries early. Hierarchical partition keys or global secondary indexes may help some access patterns, but check API support, feature limits, synchronization behavior, and cost before using them.
What are Request Units, and how should you interpret their cost?
A Request Unit (RU) is a normalized measure of the compute, I/O, and memory needed for a database operation. Reads, writes, and queries consume RUs according to item size, indexed properties, consistency, query complexity, and result size. Track the request-charge response header to observe the actual RU use of application operations. A repeated query over the same data has deterministic RU cost, but changing the data, indexes, or query shape changes that cost.
A point read using both an item ID and partition key generally costs less than a query that examines multiple partitions. Indexing every property can increase write costs; review the paths needed for filters and sorting. Removing indexes can affect query results or cause scans, so measure before changing index policy.
Should you use provisioned throughput or serverless?
Provisioned throughput assigns RU/s capacity to a container or database. It can be set manually or with autoscale; you pay for allocated capacity even when usage is low. Consider it for sustained and predictable traffic, performance guarantees, or multi-region distribution. Dedicated container throughput reserves capacity for that container and gives stronger isolation. Shared database throughput can use capacity efficiently across containers, but it does not guarantee a particular container’s share, so a busy workload can affect its neighbors.
Serverless does not require pre-provisioned RU/s and bills for consumed RUs. It can fit intermittent or irregular traffic with a low average-to-peak ratio. However, Microsoft documentation describes serverless accounts as limited to one Azure region and without the predictable throughput and latency guarantees of provisioned throughput. Compare current prices using expected monthly consumption, peaks, regional requirements, and storage; do not decide from average use alone.
How do you choose a consistency level?
Consistency defines what version of a write a read is guaranteed to see. Cosmos DB offers five levels: Strong, Bounded Staleness, Session, Consistent Prefix, and Eventual. Strong consistency gives a stronger guarantee that reads return the latest committed value, with potential costs in cross-region replication, read throughput, and latency. Weaker levels can improve availability, throughput, or latency, but a reader in another region might not immediately see a recent write.
Session is a common choice when a user should see their own recent writes. A session token can support read-your-writes behavior for a user’s successive operations, but it does not guarantee that different sessions see the latest value immediately. Read consistency applies to a read operation within one logical partition. Choose based on acceptable staleness, recovery objectives during regional disruption, read latency, and RU costs. Distinguish the account’s default from a per-request SDK override.
What do global replication and disaster recovery change?
Replicating an account across Azure regions can serve users nearer to them and help with regional outages, but it introduces replication, consistency, operational, and cost decisions. The supported write-region topology and failover behavior depend on the API and account configuration. Consistency also affects the recovery point objective: how much recent acknowledged data the application can tolerate losing during regional recovery.
Multiple regions do not replace backup and restore validation. Document which writes count as committed, how reads and writes behave during an outage, and whether applications must reconcile data after failover. Test those behaviors for the selected API and topology.
Example: how might you model order data?
Assume an order service frequently reads each customer’s history, continuously records new orders, and expects a customer to see their own order soon after submission. Using customerId as the partition key can make customer-scoped queries efficient. A high-volume customer may still concentrate traffic or data, so monitor distribution and plan for growth. Include the item ID in point reads and filter order-history queries by the customer key.
Do not guess capacity from a single benchmark. Test representative item sizes and queries, record RU charges from the SDK, and compare provisioned/autoscale with serverless using expected peaks and regional needs. Validate that Session consistency satisfies product behavior, including the order confirmation path and regional failure expectations. This scenario is illustrative; it is not a performance or cost forecast.
When might another database be a better fit?
Cosmos DB can suit globally distributed applications that need high scale, flexible document data, low response times, or one of its API ecosystems. If the workload centers on complex relational joins, relational constraints, or an existing SQL application, evaluate a relational service such as Azure SQL Database. The choice depends on queries, transaction boundaries, regional needs, development tools, operational skills, and cost model—not on whether NoSQL is newer.
References
[Microsoft Learn: Accounts, databases, containers, and items](https://learn.microsoft.com/en-us/azure/cosmos-db/resource-model)
[Microsoft Learn: Partitioning and horizontal scaling](https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning)
[Microsoft Learn: Request Units](https://learn.microsoft.com/en-us/azure/cosmos-db/request-units)
[Microsoft Learn: Provision throughput on containers and databases](https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput)
[Microsoft Learn: Provisioned throughput and serverless comparison](https://learn.microsoft.com/en-us/azure/cosmos-db/throughput-serverless)
[Microsoft Learn: Choose a consistency level](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels)
[Microsoft Learn: Serverless account performance](https://learn.microsoft.com/en-us/azure/cosmos-db/serverless-performance)
Microsoft Learn documentation was reviewed on November 20, 2026. API support, service limits, prices, and regional capabilities can change; verify current documentation before deployment.