Partition Key design in Cosmos DB is the single most important design decision for performance, scalability, and cost. The Partition Key cannot be changed later (you have to recreate the Container), so the quality of the initial design shapes everything that follows in production. This article walks through the criteria for a good Partition Key, Synthetic Key patterns, Hierarchical Partition Keys, Hot Partition mitigations, and how to pick the right RU/s throughput mode.
A Partition Key is the JSON property used to distribute documents inside a Cosmos DB Container across logical partitions.
Ideally, the Partition Key satisfies all four of the following criteria.
| Example choice | Problem |
|---|---|
| Constant value (e.g. "constant") | All data lands on a single partition and slams into the 20 GB / 10,000 RU limits |
| Sequential IDs (e.g. orderId 1, 2, 3...) | Writes concentrate on the most recent partition — Hot Write |
| Date (e.g. yyyymmdd) | Writes concentrate on today's partition — Hot Write |
| Low-cardinality tenant IDs (e.g. only 5 tenants) | Insufficient cardinality; a single large tenant creates a Hot Partition |
| A property never used in queries | Every query becomes cross-partition, multiplying cost |
| Use case | Recommended Partition Key | Why it works |
|---|---|---|
| Multi-tenant SaaS | tenantId | Many tenant-scoped queries and well-distributed writes |
| IoT sensor data | deviceId | Per-device reads with distributed writes |
| User profiles | userId | Per-user access and high cardinality |
| E-commerce order history | customerId | Per-customer history queries and distributed writes |
| Game player sessions | gameId + playerId | Access patterns scoped by both game and player |
A Synthetic Partition Key concatenates multiple properties to artificially boost cardinality.
doc.partitionKey = `${doc.tenantId}_${getCurrentMonth()}`)Hierarchical Partition Keys, GA'd in 2023, let you declare up to 3 levels of Partition Key.
What used to require a Synthetic Key for hierarchical fan-out can now be expressed declaratively and more efficiently. It is ideal for multi-tenant SaaS workloads with multi-level query patterns like "tenant-level aggregations, user-level operations, session-level details." For new projects that match this hierarchy, adopting a Hierarchical Partition Key is the modern best practice.
Cross-partition queries fan out across every Physical Partition, multiplying cost and significantly increasing latency.
Each Cosmos DB Physical Partition is capped at 20 GB of data and 10,000 RU/s of throughput.
| Mode | Pricing | Best for | Constraints |
|---|---|---|---|
| Manual Provisioned | Fixed monthly RU/s | Steady workloads | Min 400 RU/s |
| Autoscale Provisioned | Max RU/s × 1.5 | Variable workloads (30%+) | Auto-scales between 10-100% |
| Serverless | Pay-per-use | Dev / low-traffic workloads | ~5,000 RU/s ceiling, 1 TB data |
In production, Reserved Capacity (1-3 year terms) yields 20-65% discounts and should be a core part of cost optimization.
What is a Partition Key?
A Partition Key is a JSON property that distributes documents inside a Cosmos DB Container (the equivalent of a table) across logical partitions. Cosmos DB stores data physically across multiple Physical Partitions (up to 20 GB / 10,000 RU/s each), and the hash of the Partition Key value determines which physical partition a document lands on. Choosing the Partition Key is the single most important design decision in Cosmos DB — it affects performance, scalability, and cost, and it cannot be changed after the fact (you have to recreate the Container). A good Partition Key: 1) has high cardinality (1,000+ distinct values recommended), 2) spreads access patterns evenly (avoiding Hot Partitions), 3) appears in frequently filtered queries (avoiding cross-partition queries), and 4) distributes writes (avoiding throttling).
What makes a good Partition Key?
Ideally a Partition Key satisfies all four conditions: 1) high cardinality (lots of distinct values, 1,000+ recommended); 2) even access patterns (no Hot Partition, no concentration on a few values); 3) frequently used as a query filter (so most queries are in-partition rather than cross-partition); and 4) evenly distributed writes (so you avoid throttling on a Hot Write Partition). For example, in a multi-tenant SaaS, using tenantId as the Partition Key can cause a Hot Partition when one large tenant generates 10x the traffic — in that case a synthetic key like tenantId + bucketId is needed. If you cannot find a single key that satisfies all four conditions, you must consider a Hierarchical Partition Key (up to 3 levels) or a Synthetic Key from the start.
What is a Synthetic Partition Key?
A Synthetic Partition Key combines multiple properties into a single key to artificially boost cardinality. Examples: tenantId_yyyymm (tenant ID + year-month for monthly buckets), userId_random0-99 (user ID + random 0-99 to spread by 100x), or deviceId_yyyymmdd (device ID + date for daily buckets). On the write path, you build the synthetic key in JavaScript by concatenating the source properties, store it as a new property, and designate it as the Partition Key. On the read path, queries must reconstruct the same synthetic key for filtering. Trade-offs: the write-side application has to be modified, and certain range queries may become cross-partition. It is a particularly effective way to avoid Hot Partitions in multi-tenant SaaS where large and small tenants are mixed together.
What is a Hierarchical Partition Key?
Hierarchical Partition Keys, GA'd in 2023, let you declare up to 3 partitioning levels. For example, with TenantId / UserId / SessionId you get three query modes: (1) filter on TenantId alone — cross-partition but scoped to one tenant; (2) filter on TenantId + UserId — all of one user's sessions; (3) filter on TenantId + UserId + SessionId — fully in-partition. What previously required a Synthetic Key can now be expressed declaratively and run more efficiently. It is ideal for multi-tenant SaaS workloads with multi-level query patterns like 'tenant-level aggregations, user-level operations, session-level details.' For new projects that match this hierarchy, adopting a Hierarchical Partition Key is the modern best practice.
Should you avoid cross-partition queries?
Avoid them where they matter most: cost and latency rise sharply, but eliminating every cross-partition query is unrealistic, so the rule is 'avoid them on the hot path.' Cross-partition queries fan out across every Physical Partition, multiplying cost and latency. In-partition queries (those that include the Partition Key in the WHERE clause) hit just one Physical Partition, with low cost and low latency. The standard pattern: design high-traffic user-facing queries as in-partition (require the Partition Key as a filter), tolerate cross-partition queries on low-traffic admin dashboards, and offload cross-partition aggregations to Synapse Link to keep the load off Cosmos DB. In production, monitor the x-ms-request-charge response header so you can detect unintended cross-partition queries early.
What is the 20 GB / 10,000 RU limit?
Each Cosmos DB Physical Partition is capped at 20 GB of data and 10,000 RU/s of throughput. The Partition Key value determines the logical partition, and multiple logical partitions map onto a single Physical Partition. If a logical partition becomes a hot spot and hits 10,000 RU/s, you get throttling (HTTP 429). As data approaches 20 GB, Cosmos DB automatically Splits into a new Physical Partition. To deal with Hot Partitions: 1) revisit the Partition Key design to spread load, 2) use a Synthetic Key to fan out artificially, 3) provision more RU (up to the limit) if the workload is read-heavy, or 4) batch/queue writes at the application layer if writes are concentrated. In production, watch partition utilization in Cosmos DB Insights and reconsider the design once any partition exceeds 80%.
How do you choose the RU/s billing mode?
Cosmos DB offers three throughput modes: 1) Manual Provisioned — fixed RU/s, the most predictable cost, ideal for steady workloads, starting at 400 RU/s; 2) Autoscale Provisioned — you set a max RU/s (e.g. 10,000), and Cosmos DB scales between 10% (1,000) and 100% (10,000); the monthly bill is capped at 1.5x the max RU, suited to variable workloads; 3) Serverless — pay only for what you consume, no throughput floor (effective ceiling around 5,000 RU/s and up to 1 TB of data), ideal for dev/test and low-traffic workloads. Rule of thumb: steady → Manual, ±30%+ variance → Autoscale, low-traffic/dev → Serverless. In production, Reserved Capacity (1-3 year terms) yields 20-65% discounts and should be a core part of your cost optimization plan.
Which certifications cover this material?
DP-420 (Cosmos DB Developer Specialty) is the headline exam for this area and tests Partition Key design in depth. AZ-204 (Developer Associate, retiring 2026-07) covers Cosmos DB SDK operations in Domain 2 (Storage, 15-20%). AZ-305 (Solutions Architect Expert) Domain 2 covers data storage selection (API choice and consistency levels). DP-700 (Fabric Data Engineer) covers real-time analytics integration via Synapse Link. AI-103 (GA 2026-06) covers patterns for using Cosmos DB as a generative AI / RAG backend. Cosmos DB is Azure's flagship NoSQL database, and Partition Key design is an essential skill for every engineer working in this space.
Related Articles & Deeper Dives
Azure AI エンジニア キャリアロードマップ|AI-901 → AI-103 → 生成 AI アーキテクトへの道【2026 年版】
Azure AI エンジニアになるための認定取得ロードマップ完全版。AI-901 (2026-06 GA、AI-900 後継) → AI-103 (2026-06 GA、AI-102 後継) の最新ルート、Azure AI Foundry / Agent Service / OpenAI 中心の生成 AI 時代の構成、Databricks GenAI / OpenAI Direct との二刀流戦略、年収レンジまで日本語で網羅。
DP-420 完全ガイド|Microsoft Cosmos DB Developer Specialty 出題範囲・学習リソース・合格戦略【2026 年版】
Microsoft Certified: Cosmos DB Developer Specialty (DP-420) の完全ガイド。5 ドメインの出題範囲、Cosmos DB for NoSQL の Partition Key 設計、Consistency Level、RU/s 最適化、Change Feed、Synapse Link 統合、3 ヶ月の合格ロードマップ、AZ-305 / AI-103 への展開ルートを日本語で網羅。
AI-103 完全ガイド|Developing AI Apps and Agents on Azure【2026 年 6 月 GA・AI-102 後継】
Microsoft Certified: Developing AI Apps and Agents on Azure (AI-103) の完全ガイド。AI-102 の後継として 2026 年 6 月 30 日 GA。Azure AI Foundry / Agent Service / OpenAI / AI Search を中心に、RAG パターン・Agent オーケストレーション・Responsible AI・Semantic Kernel SDK の実装スキル、3-4 ヶ月の合格ロードマップを日本語で網羅。
Azure データエンジニア キャリアロードマップ|DP-900 → DP-700 → AI-103 シニアデータエンジニアへの道【2026 年版】
Azure データエンジニアになるための認定取得ロードマップ完全版。DP-900 → DP-700 → DP-600 / DP-300 の Fabric 時代の王道ルート、Databricks 認定との二刀流、AI-103 統合戦略、DP-203 リタイア後の選択、12-18 ヶ月の学習プラン、年収レンジまで日本語で網羅。
The technical information in this article is based on the Azure Cosmos DB Partitioning Documentation. This article is not an official Microsoft Corporation product and there is no partnership or sponsorship relationship. Microsoft, Azure, and Azure Cosmos DB are trademarks of the Microsoft group of companies. Information is based on official public materials as of May 24, 2026. Always check the official pages for the latest details.
Practice with certification-focused question sets
Explore Azure exam prepNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
AZ-900 Azure Fundamentals: Complete Exam Guide (2026)
Pass AZ-900 — cloud concepts, Azure architecture, management...
Azure Certification Roadmap: Which Cert to Take Next (2026)
Choose your Azure certification path — Fundamentals, Associa...
AI-901 Azure AI Fundamentals (Beta): Complete Guide (2026)
Pass AI-901 — Microsoft Foundry, generative AI, responsible ...
Microsoft Entra ID Fundamentals for Azure Certs (2026)
Entra ID basics every cert candidate needs — tenants, identi...
DP-900 Azure Data Fundamentals: Complete Guide (2026)
Pass DP-900 — relational, non-relational, analytics, Power B...