Databases Azure Cosmos DB premium

Logical partition

A logical partition is all the Cosmos DB items that have the same partition key value. If a container uses customerId as its partition key, then every item for customer 123 belongs to one logical partition. This is not the same as a physical partition, which Azure manages behind the scenes. In plain English, the logical partition is the data bucket your partition key creates. It matters because one hot or oversized bucket can slow an application, hit storage limits, or make queries more expensive.

Aliases
No aliases mapped yet
Difficulty
intermediate
CLI mappings
4
Last verified
2026-05-16

Microsoft Learn

A logical partition in Azure Cosmos DB is the group of items that share the same partition key value inside a container, forming the unit Azure uses to organize storage, route requests, and enforce important scale limits in governed production environments.

Microsoft Learn: Partitioning and horizontal scaling in Azure Cosmos DB2026-05-16

Technical context

Technically, a logical partition exists inside an Azure Cosmos DB container and is identified by one partition key value. Cosmos DB maps many logical partitions onto physical partitions, distributes request units, and uses the partition key to route point reads, writes, and queries. Each logical partition has storage limits, and poor key choice can create hot partitions that consume disproportionate throughput. Operators inspect the container partition key path, throughput model, metrics, normalized request unit consumption, storage by partition key, and query patterns. CLI cannot list every logical partition directly, so diagnostics and metrics are essential.

Why it matters

A logical partition matters because partition key design is one of the most important Cosmos DB architecture choices. A high-cardinality, evenly used key lets the container scale across many logical partitions and physical partitions. A low-cardinality or skewed key can overload one logical partition, concentrate request units, and eventually hit storage limits. Application teams often discover the problem late, after writes fail or queries become expensive. Understanding logical partitions helps architects choose better keys, developers write efficient point reads, and operators detect hot keys before customer impact. It also explains why changing a partition key usually requires data migration, not a quick setting update.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In Cosmos DB container design, the partition key path determines which items share a logical partition and how point reads or queries route during release review, incident triage, and ownership checks.

Signal 02

In Azure Monitor metrics, hot or oversized partition key values show up through throttling, storage growth, request unit use, and uneven workload patterns during release review, incident triage, and ownership checks.

Signal 03

In application code, point reads and targeted queries include the partition key value so requests stay inside one efficient logical partition during release review, incident triage, and ownership checks.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Design a Cosmos DB container partition key that spreads tenants, devices, orders, or sessions across many logical partitions.
  • Diagnose throttling where one partition key value is hot even though account-level throughput looks sufficient.
  • Plan a migration when a logical partition is approaching storage limits or the partition key no longer fits access patterns.
  • Tune queries so common reads include partition key values instead of expensive cross-partition fan-out.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Fixing hot tenant writes in SaaS telemetry

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

DatumTrail, a SaaS observability vendor, saw one enterprise tenant consume most request units in a telemetry container while smaller tenants remained healthy.

Business/Technical Objectives
  • Identify whether throttling came from one hot logical partition.
  • Support the largest tenant without raising global throughput excessively.
  • Keep normal tenant query latency under 50 milliseconds.
  • Avoid data loss during partition-key redesign.
Solution Using Logical partition

Architects reviewed the container partition key and found that tenantId alone created a large hot logical partition for the biggest customer. Operators captured container configuration with CLI, then used Azure Monitor metrics and application traces to confirm skewed request unit consumption. The team created a new container using a synthetic partition key combining tenantId and time bucket for telemetry writes. Change feed processing backfilled historical data while the application dual-wrote during validation. Query code was updated to include both key parts for common reads, and dashboards tracked throttling by tenant during cutover. The runbook also named Logical partition ownership, rollback evidence, and validation checks so support could repeat the pattern safely. The product team tested projected tenant growth against partition metrics before onboarding the customer.

Results & Business Impact
  • Throttled requests for the largest tenant fell by 88%.
  • Average query latency for normal tenants stayed below 40 milliseconds.
  • Global throughput was reduced 30% from the emergency peak.
  • Backfill completed with zero confirmed data loss.
Key Takeaway for Glossary Readers

Logical partition design must reflect the hottest real workload, not just the average tenant model.

Case study 02

Scaling IoT device data without fan-out

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

Northwind Energy stored meter readings in Cosmos DB but dashboards were running cross-partition queries for every device status refresh.

Business/Technical Objectives
  • Reduce dashboard query request units by at least 40%.
  • Keep latest device reads under 200 milliseconds.
  • Avoid changing the physical infrastructure blindly.
  • Train developers to include partition key values in reads.
Solution Using Logical partition

The data team confirmed the container partition key was deviceId, but dashboard code queried by customer region without passing device IDs. Operators used CLI to show container configuration and metrics to prove throughput was not evenly consumed. Developers changed the API to resolve device IDs first, then issue targeted point reads or narrow queries with the partition key. They also cached region-to-device mappings and added query diagnostics to logs. No additional throughput was added until the new pattern was measured under realistic device volume. The runbook also named Logical partition ownership, rollback evidence, and validation checks so support could repeat the pattern safely. Operators captured run IDs, command output, and approval notes to make the implementation auditable. Device teams added partition-key checks to their ingestion validation checklist.

Results & Business Impact
  • Dashboard request unit consumption dropped 57%.
  • Latest device panel latency improved from 480 milliseconds to 130 milliseconds.
  • No emergency throughput increase was needed after the fix.
  • Developers added partition-key checks to code review templates.
Key Takeaway for Glossary Readers

A logical partition becomes a performance advantage only when application code actually uses the partition key.

Case study 03

Preventing oversized customer buckets

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

Alpine Legal Services used Cosmos DB to store case activity records and worried that long-running enterprise cases could outgrow a single partition key value.

Business/Technical Objectives
  • Detect logical partition growth before writes fail.
  • Warn architects at 70% of the practical storage threshold.
  • Plan a migration path for oversized cases.
  • Keep compliance search behavior stable during redesign.
Solution Using Logical partition

The platform team reviewed the caseId partition key and identified several long-running matters with unusually high document counts. They built Azure Monitor alerts for partition-key storage signals and added application telemetry for case-level growth. CLI output documented the container partition key, throughput, and account regions for the architecture review. The redesign introduced a composite caseId plus bucket key for new high-volume matters, while existing cases stayed on the current container until migration was approved. Search APIs were updated to query all buckets for a case when needed. The runbook also named Logical partition ownership, rollback evidence, and validation checks so support could repeat the pattern safely. Archive owners reviewed large customer buckets during monthly capacity governance.

Results & Business Impact
  • Growth alerts gave architects 90 days of lead time.
  • No case writes failed due to partition size during the review period.
  • The migration plan was approved before the largest case reached 75% of limit.
  • Compliance search results remained consistent across old and new containers.
Key Takeaway for Glossary Readers

Monitoring logical partition growth turns a future data-model outage into a planned architecture decision.

Why use Azure CLI for this?

Azure CLI is useful for logical partitions because partition behavior must be connected to container configuration, indexing, throughput, and metrics. Commands show partition key paths and support evidence gathering before query or scale changes.

CLI use cases

  • Show a Cosmos DB container to confirm the partition key path before troubleshooting hot-key behavior.
  • List databases and containers so operators know which resource owns the suspected partitioning problem.
  • Inspect provisioned or autoscale throughput before assuming throttling requires more request units.
  • Capture account and container configuration evidence before a partition-key migration or redesign plan.

Before you run CLI

  • Confirm the Cosmos DB account, resource group, database, container, API, and subscription before trusting output.
  • Know that CLI output shows container configuration, not a complete list of logical partition key values.
  • Collect time range, partition key samples, throttling metrics, and query diagnostics before changing throughput.
  • Avoid exposing tenant IDs or customer identifiers from partition key values in shared command output or tickets.

What output tells you

  • Container output confirms the partition key path and indexing settings that shape request routing and query behavior.
  • Throughput output shows whether the container uses manual, autoscale, shared, or dedicated throughput for capacity planning.
  • Account output identifies regions and consistency settings that can influence perceived partition performance and failover behavior.
  • The absence of logical partition lists reminds operators to use metrics and diagnostics for key-level hot-spot evidence.

Mapped Azure CLI commands

Cosmos DB container and throughput inspection

Adjacent
Az cosmosdb sql container show --account-name <account-name> --resource-group <resource-group> --database-name <database-name> --name <container-name>
az cosmosdb sql containerdiscoverDatabases
Az cosmosdb sql container throughput show --account-name <account-name> --resource-group <resource-group> --database-name <database-name> --name <container-name>
az cosmosdb sql container throughputdiscoverDatabases
Az cosmosdb sql container list --account-name <account-name> --resource-group <resource-group> --database-name <database-name> --output table
az cosmosdb sql containerdiscoverDatabases
Az cosmosdb show --name <account-name> --resource-group <resource-group>
az cosmosdbdiscoverDatabases

Architecture context

Logical partition connects to Databases architecture through scope, identity, data flow, monitoring, cost, and operational ownership. Treat it as a production design checkpoint: verify the Azure resource, the caller, the dependency path, the monitoring signal, and the rollback evidence before changing it.

Security

Security impact is indirect, but logical partitions still affect data isolation assumptions. If the partition key aligns with tenant, customer, or account boundaries, application code can use it to make efficient scoped reads and reduce accidental cross-tenant queries. That does not replace authorization; RBAC, resource tokens, application checks, encryption, and network controls still matter. Poor partition design can encourage broad cross-partition queries that touch more data than necessary and increase exposure in logs, diagnostics, or application traces. Operators should review partition key values used in monitoring so sensitive tenant identifiers are not casually exported or pasted into tickets. It also supports cleaner evidence during security review and access approval.

Cost

Cost is tied to logical partitions through request unit usage, query shape, throughput allocation, and rework. A balanced partition key lets provisioned or autoscale throughput serve many keys efficiently. A skewed key can force teams to raise overall throughput just to satisfy one hot logical partition, increasing cost without helping the rest of the workload. Cross-partition queries, fan-out reads, and large tenant buckets can also increase request unit charges. The largest cost surprise is redesign: fixing a bad partition key can require data migration, parallel containers, engineering time, and dual writes. Good partition design is a FinOps decision, not only a data modeling decision.

Reliability

Reliability is directly affected by logical partition design. A hot logical partition can throttle writes, delay reads, and make an otherwise well-provisioned container feel unreliable. An oversized logical partition can hit storage limits and block further growth for that key. Because the partition key is chosen at container creation, fixing the wrong design often requires new containers, data copy, application changes, and migration planning. Use metrics and alerts for storage and normalized request unit consumption by partition key where available. Reliability reviews should test expected worst-case tenants, devices, accounts, or regions, not only average traffic across the whole container. It also gives responders a safer signal during outage triage.

Performance

Performance depends heavily on whether requests can target one logical partition. Point reads and writes with the correct partition key are efficient because Cosmos DB can route them precisely. Queries that omit the partition key may fan out across many partitions and consume more request units. Hot logical partitions can create throttling even when average container metrics look acceptable. Model access patterns before choosing the key: tenant, device, session, user, order, and synthetic keys behave differently under real load. Watch p95 latency, throttled requests, normalized request unit consumption, and query diagnostics. Partition design usually beats adding throughput after the fact.

Operations

Operations teams monitor logical partitions through Cosmos DB metrics, alerts, workload traces, query diagnostics, and container configuration. Runbooks should explain the partition key path, expected cardinality, largest tenants or keys, hot-key symptoms, and migration plan if a key approaches limits. CLI is useful for inspecting account, database, container, and throughput settings, but partition health usually requires Azure Monitor metrics, portal insights, or application telemetry. Operators should investigate throttling by key, storage concentration, and cross-partition query spikes. During migrations, track change feed, backfill progress, consistency requirements, and application rollout carefully. It also makes ownership and rollback easier for the support team.

Common mistakes

  • Choosing a partition key with too few values, then blaming Cosmos DB when one logical partition becomes hot.
  • Assuming higher account throughput fixes a single hot key without checking normalized request unit consumption by partition.
  • Designing queries that omit partition key values even though the application usually knows the tenant or entity ID.
  • Treating partition key migration as a quick setting change instead of a container, data, and application migration.