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 Limit
Maximum RUs per container (dedicated throughput provisioned mode) 1,000,000 1
Maximum RUs per database (shared throughput provisioned mode) 1,000,000 1
Maximum RUs per partition (logical & physical) 10,000
Maximum storage across all items per (logical) partition 20 GB 2
Maximum number of distinct (logical) partition keys Unlimited
Maximum storage per container Unlimited
Maximum attachment size per Account (Attachment feature is being deprecated) 2 GB
Minimum RU/s required per 1 GB 10 RU/s 3

1 You can increase Maximum RUs per container or database by filing an Azure support ticket.

2 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. If your workload has already reached the logical partition limit of 20 GB in production, it's recommended to rearchitect your application with a different partition key as a long-term solution. To help give time to rearchitect your application, you can request a temporary increase in the logical partition key limit for your existing application. File an Azure support ticket and select quota type Temporary increase in container's logical partition key size. Requesting a temporary increase is intended as a temporary mitigation and not recommended as a long-term solution, as SLA guarantees are not honored when the limit is increased. To remove the configuration, file a support ticket and select quota type Restore container’s logical partition key size to default (20 GB). Filing this support ticket can be done after you have either deleted data to fit the 20-GB logical partition limit or have rearchitected your application with a different partition key.

3 Minimum can be lowered if your account is eligible to our "high storage / low throughput" program

Minimum throughput limits

A Cosmos container (or shared throughput database) using manual throughput 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

For example, 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

For example, 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 when using manual throughput.

Resource Limit
Minimum RUs per container (dedicated throughput provisioned mode with manual throughput) 400
Minimum RUs per database (shared throughput provisioned mode with manual throughput) 400 RU/s for first 25 containers.

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. Learn more.

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. These limits can't be increased. It's recommended to provision extra serverless accounts for more storage needs.

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 (SQL API, Mongo API, Table API, Gremlin API) 50 GB
Maximum storage per container (Cassandra API) 30 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 Limit
Maximum number of accounts per subscription 50 by default. 1
Maximum number of regional failovers 1/hour by default. 1 2

1 You can increase these limits by creating an Azure Support request.

2 Regional failovers only apply to single region writes accounts. Multi-region write accounts don't 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 Limit
Maximum number of databases per account 500
Maximum number of containers per database with shared throughput 25
Maximum number of containers per account 500
Maximum number of regions No limit (All Azure regions)

Serverless

Resource Limit
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 Limit
Maximum length of database or container name 255
Maximum number of stored procedures per container 100 1
Maximum number of UDFs per container 50 1
Maximum number of paths in indexing policy 100 1
Maximum number of unique keys per container 10 1
Maximum number of paths per unique key constraint 16 1
Maximum TTL value 2147483647

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

Per-item limits

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; depending on which API you use. The following table shows the limits per item in Cosmos DB.

Resource Limit
Maximum size of an item 2 MB (UTF-8 length of JSON representation) 1
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

1 Large document sizes up to 16 Mb are currently in preview with Azure Cosmos DB API for MongoDB only. Sign-up for the feature “Azure Cosmos DB API For MongoDB 16MB Document Support” from Preview Features the Azure portal, to try the new feature.

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 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's 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 token for fine-grained access control to resources. These resources can include containers, partition keys, or items. The following table lists limits for authorization tokens in Cosmos DB.

Resource Limit
Maximum primary token expiry time 15 min
Minimum resource token expiry time 10 min
Maximum resource token expiry time 24 h by default 1
Maximum clock skew for token authorization 15 min

1 You can increase it by filing an Azure support ticket

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 Limit
Maximum collection create rate per minute 100
Maximum Database create rate per minute 100
Maximum provisioned throughput update rate per minute 5
Maximum throughput supported by an account for metadata operations 240 RU/s

Limits for autoscale provisioned throughput

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

Resource 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're 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(1000, 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(1000, highest max RU/s ever provisioned / 10, current storage in GB * 100, 1000 + (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 6000 RU/s (scales between 600 - 6000 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 Limit
Maximum length of SQL query 256 KB
Maximum JOINs per query 10 1
Maximum UDFs per query 10 1
Maximum points per polygon 4096
Maximum included paths per container 500
Maximum excluded paths per container 500
Maximum properties in a composite index 8

1 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 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 1 30 minutes

1 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 aren't 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 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 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: