Azure Cosmos DB service quotas

APPLIES TO: SQL API Cassandra API Gremlin API Table API Azure Cosmos DB API for MongoDB

This article provides an overview of the default quotas offered to different resources in the Azure Cosmos DB.

Storage and database operations

After you create an Azure Cosmos account under your subscription, you can manage data in your account by creating databases, containers, and items.

Provisioned throughput

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. Storage refers to the combined amount of data and index storage.

Resource Default limit
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 partition (logical & physical) 10,000
Maximum storage across all items per (logical) partition 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 deprecated) 2 GB
Minimum RU/s required per 1 GB 10 RU/s
Note: this minimum can be lowered if your account is eligible to our "high storage / low throughput" program

Note

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.

Minimum throughput limits

A Cosmos container (or shared throughput database) must have a minimum throughput of 400 RU/s. As the container grows, Cosmos DB requires a minimum throughput to ensure the database or container has sufficient resource for its operations.

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.

The actual minimum RU/s may vary depending on your account configuration. You can use Azure Monitor metrics to view the history of provisioned throughput (RU/s) and storage on a resource.

Minimum throughput on container

To estimate the minimum throughput required of a container with manual throughput, find the maximum of:

  • 400 RU/s
  • Current storage in GB * 10 RU/s
  • Highest RU/s ever provisioned on the container / 100

Example: Suppose you have a container provisioned with 400 RU/s and 0 GB storage. You increase the throughput to 50,000 RU/s and import 20 GB of data. The minimum RU/s is now MAX(400, 20 * 10 RU/s per GB, 50,000 RU/s / 100) = 500 RU/s. Over time, the storage grows to 200 GB. The minimum RU/s is now MAX(400, 200 * 10 RU/s per GB, 50,000 / 100) = 2000 RU/s.

Note: the minimum throughput of 10 RU/s per GB of storage can be lowered if your account is eligible to our "high storage / low throughput" program.

Minimum throughput on shared throughput database

To estimate the minimum throughput required of a shared throughput database with manual throughput, find the maximum of:

  • 400 RU/s
  • Current storage in GB * 10 RU/s
  • Highest RU/s ever provisioned on the database / 100
  • 400 + MAX(Container count - 25, 0) * 100 RU/s

Example: Suppose you have a database provisioned with 400 RU/s, 15 GB of storage, and 10 containers. The minimum RU/s is MAX(400, 15 * 10 RU/s per GB, 400 / 100, 400 + 0 ) = 400 RU/s. If there were 30 containers in the database, the minimum RU/s would be 400 + MAX(30 - 25, 0) * 100 RU/s = 900 RU/s.

Note: the minimum throughput of 10 RU/s per GB of storage can be lowered if your account is eligible to our "high storage / low throughput" program.

In summary, here are the minimum provisioned RU limits.

Resource Default limit
Minimum RUs per container (dedicated throughput provisioned mode) 400
Minimum RUs per database (shared throughput provisioned mode) 400 RU/s for first 25 containers. Additional 100 RU/s for each container afterward.

Cosmos DB supports programmatic scaling of throughput (RU/s) per container or database via the SDKs or portal.

Depending on the current RU/s provisioned and resource settings, each resource can scale synchronously and immediately between the minimum RU/s to up to 100x the minimum RU/s. 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.

Serverless

Serverless lets you use your Azure Cosmos DB resources in a consumption-based fashion. The following table lists the limits for storage and throughput burstability per container/database.

Resource Limit
Maximum RU/s per container 5,000
Maximum storage across all items per (logical) partition 20 GB
Maximum number of distinct (logical) partition keys Unlimited
Maximum storage per container 50 GB

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.

Resource Default limit
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

Note

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.

Per-account limits

Provisioned throughput

Resource Default limit
Maximum number of databases 500
Maximum number of containers per database with shared throughput 25
Maximum number of containers per database or account with dedicated throughput 500
Maximum number of regions No limit (All Azure regions)

Serverless

Resource Limit
Maximum number of databases 500
Maximum number of containers per account 100
Maximum number of regions 1 (Any Azure region)

Per-container limits

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.

Resource Default limit
Maximum length of database or container name 255
Maximum stored procedures per container 100 *
Maximum UDFs per container 50 *
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 *
Maximum TTL value 2147483647

* You can increase any of these per-container limits by creating an Azure Support request.

Per-item limits

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.

Resource Default limit
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 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
Maximum level of nesting for embedded objects / arrays 128
Maximum TTL value 2147483647

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.

Per-request limits

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.

Resource Default limit
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 primary 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.

Resource Default limit
Maximum primary 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.

Metadata request limits

Azure Cosmos DB maintains system metadata for each account. This metadata allows you to enumerate collections, databases, other Azure Cosmos DB resources, and their configurations for free of charge.

Resource Default limit
Maximum collection create rate per minute 100
Maximum Database create rate per minute 100
Maximum provisioned throughput update rate per minute 5

Limits for autoscale provisioned throughput

See the Autoscale article and FAQ for more detailed explanation of the throughput and storage limits with autoscale.

Resource Default limit
Maximum RU/s the system can scale to Tmax, the autoscale max RU/s set by user
Minimum RU/s the system can scale to 0.1 * Tmax
Current RU/s the system is scaled to 0.1*Tmax <= T <= Tmax, based on usage
Minimum billable RU/s per hour 0.1 * Tmax

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 0.1*Tmax, whichever is higher.
Minimum autoscale max RU/s for a container MAX(4000, highest max RU/s ever provisioned / 10, current storage in GB * 100) rounded to nearest 1000 RU/s
Minimum autoscale max RU/s for a database MAX(4000, highest max RU/s ever provisioned / 10, current storage in GB * 100, 4000 + (MAX(Container count - 25, 0) * 1000)), rounded to nearest 1000 RU/s.

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.

Resource Default limit
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 any of these SQL query limits by creating an Azure Support request.

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.

Resource Default limit
Maximum MongoDB query memory size (This limitation is only for 3.2 server version) 40 MB
Maximum execution time for MongoDB operations (for 3.2 server version) 15 seconds
Maximum execution time for MongoDB operations(for 3.6 and 4.0 server version) 60 seconds
Maximum level of nesting for embedded objects / arrays on index definitions 6
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.

Resource Default limit
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.

Azure Cosmos DB free tier account limits

The following table lists the limits for Azure Cosmos DB free tier accounts.

Resource Default limit
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 1000 RU/s
Maximum storage for free 25 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. To learn more, see how to free tier account article.

Next steps

Read more about Cosmos DB's core concepts global distribution and partitioning and provisioned throughput.

Get started with Azure Cosmos DB with one of our quickstarts: