Azure Cosmos DB service quotas
This article provides an overview of the default quotas offered to different resources in the Azure Cosmos DB.
Storage and throughput
After you create an Azure Cosmos account under your subscription, you can manage data in your account by creating databases, containers, and items. You can provision throughput at a container-level or a database-level in terms of request units (RU/s or RUs). The following table lists the limits for storage and throughput per container/database.
|Maximum RUs per container (dedicated throughput provisioned mode)||1,000,000 by default. You can increase it by filing an Azure support ticket|
|Maximum RUs per database (shared throughput provisioned mode)||1,000,000 by default. You can increase it by filing an Azure support ticket|
|Maximum RUs per (logical) partition key||10,000|
|Maximum storage across all items per (logical) partition key||20 GB|
|Maximum number of distinct (logical) partition keys||Unlimited|
|Maximum storage per container||Unlimited|
|Maximum storage per database||Unlimited|
|Maximum attachment size per Account (Attachment feature is being depreciated)||2 GB|
|Minimum RUs required per 1 GB||10 RU/s|
To learn about best practices for managing workloads that have partition keys requiring higher limits for storage or throughput, see Create a synthetic partition key.
A Cosmos container (or shared throughput database) must have a minimum throughput of 400 RU/s. As the container grows, the minimum supported throughput also depends on the following factors:
- The maximum throughput ever provisioned on the container. For example, if your throughput was increased to 50,000 RU/s, then the lowest possible provisioned throughput would be 500 RU/s
- The current storage in GB in the container. For example, if your container has 100 GB of storage, then the lowest possible provisioned throughput would be 1000 RU/s
- The minimum throughput on a shared throughput database also depends on the total number of containers that you have ever created in a shared throughput database, measured at 100 RU/s per container. For example, if you have created five containers within a shared throughput database, then the throughput must be at least 500 RU/s
The current and minimum throughput of a container or a database can be retrieved from the Azure portal or the SDKs. For more information, see Provision throughput on containers and databases.
In some cases, you may be able to lower throughput to lesser than 10%. Use the API to get the exact minimum RUs per container.
In summary, here are the minimum provisioned RU limits.
|Minimum RUs per container (dedicated throughput provisioned mode)||400|
|Minimum RUs per database (shared throughput provisioned mode)||400|
|Minimum RUs per container within a shared throughput database||100|
Cosmos DB supports elastic scaling of throughput (RUs) per container or database via the SDKs or portal. Each container can scale synchronously and immediately within a scale range of 10 to 100 times, between minimum and maximum values. If the requested throughput value is outside the range, scaling is performed asynchronously. Asynchronous scaling may take minutes to hours to complete depending on the requested throughput and data storage size in the container.
Control plane operations
You can provision and manage your Azure Cosmos account using the Azure portal, Azure PowerShell, Azure CLI, and Azure Resource Manager templates. The following table lists the limits per subscription, account, and number of operations.
|Maximum database accounts per subscription||50 by default. You can increase it by filing an Azure support ticket|
|Maximum number of regional failovers||1/hour by default. You can increase it by filing an Azure support ticket|
Regional failovers only apply to single region writes accounts. Multi-region write accounts do not require or have any limits on changing the write region.
Cosmos DB automatically takes backups of your data at regular intervals. For details on backup retention intervals and windows, see Online backup and on-demand data restore in Azure Cosmos DB.
|Maximum number of databases||Unlimited|
|Maximum number of containers per database with shared throughput||25|
|Maximum number of containers per database or account with dedicated throughput||unlimited|
|Maximum number of regions||No limit (All Azure regions)|
Depending on which API you use, an Azure Cosmos container can represent either a collection, a table, or graph. Containers support configurations for unique key constraints, stored procedures, triggers, and UDFs, and indexing policy. The following table lists the limits specific to configurations within a container.
|Maximum length of database or container name||255|
|Maximum stored procedures per container||100 *|
|Maximum UDFs per container||25 *|
|Maximum number of paths in indexing policy||100 *|
|Maximum number of unique keys per container||10 *|
|Maximum number of paths per unique key constraint||16 *|
* You can increase any of these per-container limits by contacting Azure Support.
Depending on which API you use, an Azure Cosmos item can represent either a document in a collection, a row in a table, or a node or edge in a graph. The following table shows the limits per item in Cosmos DB.
|Maximum size of an item||2 MB (UTF-8 length of JSON representation)|
|Maximum length of partition key value||2048 bytes|
|Maximum length of ID value||1023 bytes|
|Maximum number of properties per item||No practical limit|
|Maximum nesting depth||No practical limit|
|Maximum length of property name||No practical limit|
|Maximum length of property value||No practical limit|
|Maximum length of string property value||No practical limit|
|Maximum length of numeric property value||IEEE754 double-precision 64-bit|
There are no restrictions on the item payloads like number of properties and nesting depth, except for the length restrictions on partition key and ID values, and the overall size restriction of 2 MB. You may have to configure indexing policy for containers with large or complex item structures to reduce RU consumption. See Modeling items in Cosmos DB for a real-world example, and patterns to manage large items.
Azure Cosmos DB supports CRUD and query operations against resources like containers, items, and databases. It also supports transactional batch requests against multiple items with the same partition key in a container.
|Maximum execution time for a single operation (like a stored procedure execution or a single query page retrieval)||5 sec|
|Maximum request size (for example, stored procedure, CRUD)||2 MB|
|Maximum response size (for example, paginated query)||4 MB|
|Maximum number of operations in a transactional batch||100|
Once an operation like query reaches the execution timeout or response size limit, it returns a page of results and a continuation token to the client to resume execution. There is no practical limit on the duration a single query can run across pages/continuations.
Cosmos DB uses HMAC for authorization. You can use either a master key, or a resource tokens for fine-grained access control to resources like containers, partition keys, or items. The following table lists limits for authorization tokens in Cosmos DB.
|Maximum master token expiry time||15 min|
|Minimum resource token expiry time||10 min|
|Maximum resource token expiry time||24 h by default. You can increase it by filing an Azure support ticket|
|Maximum clock skew for token authorization||15 min|
Cosmos DB supports execution of triggers during writes. The service supports a maximum of one pre-trigger and one post-trigger per write operation.
Limits for autoscale provisioned throughput
|Maximum RU/s the system can scale to||
|Minimum RU/s the system can scale to||
|Current RU/s the system is scaled to||
|Minimum billable RU/s per hour||
Billing is done on a per-hour basis, where you are billed for the highest RU/s the system scaled to in the hour, or
|Minimum autoscale max RU/s for a container||
|Minimum autoscale max RU/s for a database||
Note if your database has more than 25 containers, the system increments the minimum autoscale max RU/s by 1000 RU/s per additional container. For example, if you have 30 containers, the lowest autoscale maximum RU/s you can set is 9000 RU/s (scales between 900 - 9000 RU/s).
SQL query limits
Cosmos DB supports querying items using SQL. The following table describes restrictions in query statements, for example in terms of number of clauses or query length.
|Maximum length of SQL query||256 KB|
|Maximum JOINs per query||5 *|
|Maximum UDFs per query||10 *|
|Maximum points per polygon||4096|
|Maximum included paths per container||500|
|Maximum excluded paths per container||500|
|Maximum properties in a composite index||8|
* You can increase these SQL query limits by contacting Azure Support.
MongoDB API-specific limits
Cosmos DB supports the MongoDB wire protocol for applications written against MongoDB. You can find the supported commands and protocol versions at Supported MongoDB features and syntax.
The following table lists the limits specific to MongoDB feature support. Other service limits mentioned for the SQL (core) API also apply to the MongoDB API.
|Maximum MongoDB query memory size (This limitation is only for 3.2 server version)||40 MB|
|Maximum execution time for MongoDB operations||30s|
|Idle connection timeout for server side connection closure*||30 minutes|
* We recommend that client applications set the idle connection timeout in the driver settings to 2-3 minutes because the default timeout for Azure LoadBalancer is 4 minutes. This timeout will ensure that idle connections are not closed by an intermediate load balancer between the client machine and Azure Cosmos DB.
Try Cosmos DB Free limits
The following table lists the limits for the Try Azure Cosmos DB for Free trial.
|Duration of the trial||30 days (a new trial can be requested after expiration)
After expiration, the information stored is deleted.
|Maximum containers per subscription (SQL, Gremlin, Table API)||1|
|Maximum containers per subscription (MongoDB API)||3|
|Maximum throughput per container||5000|
|Maximum throughput per shared-throughput database||20000|
|Maximum total storage per account||10 GB|
Try Cosmos DB supports global distribution in only the Central US, North Europe, and Southeast Asia regions. Azure support tickets can't be created for Try Azure Cosmos DB accounts. However, support is provided for subscribers with existing support plans.
Free tier account limits
The following table lists the limits for Azure Cosmos DB free tier accounts.
|Number of free tier accounts per Azure subscription||1|
|Duration of free-tier discount||Lifetime of the account. Must opt-in during account creation.|
|Maximum RU/s for free||400 RU/s|
|Maximum storage for free||5 GB|
|Maximum number of shared throughput databases||5|
|Maximum number of containers in a shared throughput database||25
In free tier accounts, the minimum RU/s for a shared throughput database with up to 25 containers is 400 RU/s.
In addition to the above, the Per-account limits also apply to free tier accounts.
Get started with Azure Cosmos DB with one of our quickstarts: