Azure Cosmos DB is often used by applications that handle several types of database operations through the same container. A typical application might process customer requests, run background jobs, import data, update search indexes, and execute reporting queries. Although these operations have different priorities, they can compete for the same provisioned throughput.
This competition can affect application performance. For example, a background data import may generate a large number of writes and consume a significant portion of the available request units (RUs). As a result, customer-facing requests may experience higher latency or receive HTTP 429 throttling responses.
Increasing the container's provisioned throughput can provide additional capacity, but it does not control how much throughput an individual workload can consume. Creating separate containers can provide stronger separation, but it may introduce data duplication, synchronization requirements, and additional application complexity.
Azure Cosmos DB throughput buckets provide another option. They allow developers to assign requests to workload-specific buckets and configure maximum throughput consumption limits. This makes it possible to control background processing, bulk imports, and other workloads while keeping related data in the same container.
This article explains how throughput buckets work, how to configure them, how to use them from a .NET application, and what to consider when introducing them into production systems.
Understanding Throughput Buckets in Azure Cosmos DB
Throughput buckets are a workload-level resource governance feature for Azure Cosmos DB for NoSQL. They allow multiple workloads sharing a container to have different maximum throughput consumption limits.
A throughput bucket is identified by a numeric ID from 1 to 5. Each enabled bucket can have a maximum throughput percentage configured against the container's total throughput.
For example, consider an e-commerce application with a container that has 20,000 RU/s provisioned throughput. The application runs three workloads:
- Customer-facing product searches.
- Background product imports.
- Inventory synchronization.
The development team can assign background imports to one bucket and configure that bucket with a 10% maximum throughput limit. If the container has 20,000 RU/s, that bucket can consume up to 2,000 RU/s under the configured limit.
When the bucket reaches its limit, additional requests assigned to it can be throttled. Other workloads can continue using the container's shared throughput according to their own limits and the capacity available.
The important point is that throughput buckets provide consumption limits, not reserved capacity. Configuring a bucket with a 10% maximum does not reserve the remaining 90% for other workloads. All workloads still share the container's overall throughput.
How Throughput Buckets Work
Throughput buckets sit between application requests and the container's shared throughput allocation. The application assigns requests to a bucket, and Azure Cosmos DB enforces the configured maximum consumption for that bucket.
The basic process works as follows:
- The application creates a request using the Azure Cosmos DB SDK.
- The request includes a throughput bucket ID, either through client-level configuration or request-level options.
- Azure Cosmos DB identifies the bucket associated with the request.
- The request consumes throughput from the shared container capacity, subject to the bucket's configured maximum.
- If the bucket reaches its limit, additional requests assigned to it are throttled.
Consider a container with the following configuration:
| Workload | Bucket | Maximum throughput |
|---|
| Background imports | 1 | 10% |
| Standard customer searches | 2 | 40% |
| Inventory synchronization | 3 | 20% |
| Premium customer searches | Unassigned | No bucket-specific cap |
These percentages are illustrative configuration values, not reserved allocations. An unassigned workload does not automatically receive the remaining 30% as a guaranteed allocation. It can use the container's available throughput without a bucket-specific ceiling, subject to the overall container capacity.
This distinction is important when designing workload priorities. A bucket limits how much its assigned workload can consume, but it does not guarantee that another workload will always receive a particular percentage.
Configuring Throughput Buckets in Azure Portal
Before assigning requests to buckets, configure the required buckets on the Azure Cosmos DB container.
The configuration is available through the Azure portal for supported Azure Cosmos DB for NoSQL containers.
Follow these steps:
- Open the Azure portal and navigate to your Azure Cosmos DB account.
- Open Data Explorer.
- Select the database and container you want to configure.
- Open the Scale & Settings section.
- Select the Throughput Buckets tab.
- Activate the buckets required by your application.
- Configure the maximum throughput percentage for each bucket.
- Save the configuration.
A container supports up to five throughput buckets. Their IDs range from 1 to 5, and you cannot assign custom names to them in the service configuration.
Although the service uses numeric IDs, your application should use meaningful constants or configuration values to make the code easier to understand.
For example:
public static class CosmosThroughputBuckets
{
public const int BackgroundImport = 1;
public const int StandardSearch = 2;
public const int InventorySync = 3;
}
This approach prevents developers from repeatedly using unexplained numeric values throughout the application.
Configure a default throughput bucket
A container can also have a default throughput bucket. When a request does not explicitly specify a bucket, Azure Cosmos DB assigns it to the configured default bucket.
This is useful when an application has older services or components that do not yet support explicit bucket assignment.
For example, suppose a container has bucket 5 configured as its default with a 15% maximum throughput limit. Requests that arrive without an explicit bucket assignment use bucket 5.
If the default bucket is later disabled, unassigned requests fall back to using the container's throughput without a bucket-specific limit.
A default bucket should be introduced carefully. It can provide a useful safety boundary for unclassified traffic, but it can also throttle older application components if they generate more traffic than the configured limit allows.
Using Throughput Buckets in .NET Applications
The Azure Cosmos DB .NET SDK provides throughput bucket support through client-level configuration and request-level options.
The current documentation specifies Azure Cosmos DB .NET SDK version 3.63.0 or later for the throughput bucket scenarios described here. Check the SDK version used by your application before implementing the feature.
Install or update the package:
dotnet add package Microsoft.Azure.Cosmos
Assign a bucket to an individual request
Request-level assignment is useful when a single application serves multiple types of users or executes different workloads through the same Cosmos DB client.
For example, a marketplace application might place standard customer searches in bucket 2 while allowing premium customer searches to remain unassigned.
The following example demonstrates how to assign a bucket to a query:
using Microsoft.Azure.Cosmos;
public class ProductService
{
private readonly Container _container;
public ProductService(CosmosClient client)
{
_container = client.GetContainer(
"Retail",
"Products");
}
public async Task<List<Product>> SearchStandardProductsAsync(
string categoryId)
{
var query = new QueryDefinition(
"SELECT * FROM c WHERE c.categoryId = @categoryId")
.WithParameter("@categoryId", categoryId);
var options = new QueryRequestOptions
{
PartitionKey = new PartitionKey(categoryId),
ThroughputBucket = 2
};
using FeedIterator<Product> iterator =
_container.GetItemQueryIterator<Product>(
query,
requestOptions: options);
var products = new List<Product>();
while (iterator.HasMoreResults)
{
FeedResponse<Product> response =
await iterator.ReadNextAsync();
products.AddRange(response);
}
return products;
}
}
public record Product(
string id,
string categoryId,
string name,
decimal price);
The important part is the ThroughputBucket property in QueryRequestOptions. Setting it to 2 assigns the query requests to bucket 2.
The application can use a different request option for another workload. For example, premium searches can be sent without a bucket-specific assignment if that is the intended policy.
This approach is useful when the same service handles requests with different business priorities.
Assign a bucket at the client level
When an application instance performs only one type of workload, configuring the bucket at the client level can be simpler.
For example, a background import service may perform thousands of product writes. Instead of setting the bucket on every operation, configure it when creating the Cosmos DB client.
using Azure.Identity;
using Microsoft.Azure.Cosmos;
var cosmosClient = new CosmosClientBuilder(
"https://your-account.documents.azure.com:443/",
new DefaultAzureCredential())
.WithBulkExecution(true)
.WithThroughputBucket(1)
.Build();
Container container = cosmosClient.GetContainer(
"Retail",
"Products");
All applicable requests created through this client use bucket 1.
The example also enables bulk execution, which can improve ingestion efficiency when an application sends many independent operations. Bulk execution and throughput buckets solve different problems: bulk execution optimizes how operations are submitted, while the bucket controls the workload's maximum throughput consumption.
Use separate client configurations when different services or background workers have clearly different workload responsibilities.
Assign throughput buckets to bulk operations
Bulk imports are a common reason to introduce throughput buckets. A migration or supplier import may generate a large volume of writes while the application continues serving normal customer traffic.
A dedicated client can place the import workload in a controlled bucket:
using System.Text.Json;
using Azure.Identity;
using Microsoft.Azure.Cosmos;
using CosmosClient bulkClient = new CosmosClientBuilder(
"https://your-account.documents.azure.com:443/",
new DefaultAzureCredential())
.WithBulkExecution(true)
.WithThroughputBucket(1)
.Build();
Container products = bulkClient.GetContainer(
"Retail",
"Products");
using FileStream file = File.OpenRead(
"supplier-products.json");
List<Product> items =
await JsonSerializer.DeserializeAsync<List<Product>>(file)
?? throw new InvalidDataException(
"The product file is empty.");
foreach (Product[] batch in items.Chunk(100))
{
await Task.WhenAll(
batch.Select(product =>
products.UpsertItemAsync(
product,
new PartitionKey(product.categoryId))));
}
public record Product(
string id,
string categoryId,
string name,
decimal price);
This example assigns the import client to bucket 1. The import operations are therefore subject to the maximum throughput configured for that bucket.
The batch size of 100 is an application-level example, not a recommended universal value. Choose a batch size based on memory usage, request behavior, retry handling, and the rate at which the source data can be processed.
For bulk operations, prefer client-level or bulk-request-level bucket assignment rather than setting a bucket separately for every individual operation.
Designing a Workload Isolation Strategy
The most important part of implementing throughput buckets is deciding which workloads should share a bucket and which should use separate buckets.
Creating a bucket for every application component is not always useful. A better approach is to group workloads according to their business purpose, priority, and resource consumption.
Separate foreground and background workloads
Foreground workloads directly affect the user experience. Examples include product searches, order lookups, customer profile requests, and checkout operations.
Background workloads can usually tolerate some delay. Examples include data imports, report generation, data cleanup, and search index updates.
A practical design might look like this:
| Workload | Suggested assignment | Reason |
|---|
| Customer-facing searches | Dedicated bucket or unassigned | Control consumption according to business priority |
| Bulk data import | Dedicated bucket | Prevent large imports from consuming excessive throughput |
| Inventory synchronization | Dedicated bucket | Control background write activity |
| Reporting queries | Dedicated bucket | Limit expensive analytical requests |
| Administrative tools | Default bucket | Provide a boundary for unclassified traffic |
The exact bucket percentages should be based on measured RU consumption and application requirements. Do not assign percentages simply because the configuration allows them.
Use buckets for multitenant applications
Multitenant applications often serve customers with different service levels. A single container may store data for multiple tenants, while the application provides different request limits or service guarantees.
Throughput buckets can help control consumption by workload tier.
For example:
- Standard-tier requests can be assigned to bucket 2.
- Background tenant synchronization can use bucket 3.
- Premium-tier requests can use a different policy based on the application's requirements.
However, throughput buckets are not a complete tenant-isolation mechanism. Requests assigned to the same bucket share that bucket's consumption limit. If individual tenants require independent resource guarantees, you may need additional application-level controls or a different data and throughput architecture.
Monitoring Throughput Bucket Usage
Configuring buckets is only the beginning. You need to monitor how each workload consumes RUs and whether the configured limits are appropriate.
Azure Cosmos DB provides metrics that can be split by throughput bucket.
The relevant metrics include:
- Total Requests: Shows request counts for each bucket.
- Total Request Units: Shows RU consumption for each bucket.
- HTTP 429 responses: Helps identify throttled requests.
In the Azure portal, open the Metrics section of the Cosmos DB account, select the database and container, and inspect the available metrics. Where supported, split the metrics by the ThroughputBucket dimension.
For example, if bucket 1 handles background imports, its RU consumption can be compared with the expected maximum. If the bucket repeatedly reaches its configured limit, the import may take longer than expected.
This is not necessarily a problem. A background job may be intentionally limited to protect customer-facing operations. However, if the import has a strict completion deadline, the bucket configuration may need to be adjusted.
Monitor application-level latency as well as database metrics. A bucket can experience throttling while the SDK retries requests successfully. In that case, the final operation may succeed, but the application can still experience higher response times.
A useful monitoring dashboard should include:
| Metric | Why it matters |
|---|
| RU consumption by bucket | Shows which workloads use the available throughput |
| Request count by bucket | Helps identify changes in workload volume |
| HTTP 429 count | Identifies throttling |
| End-to-end request latency | Shows the impact on application performance |
| Background job completion time | Helps determine whether workload limits are too restrictive |
| SDK retry activity | Shows whether throttling is affecting application operations |
Handling Throttling and Common Errors
Throughput buckets introduce additional throttling behavior that application developers should understand.
HTTP 429 with substatus 3212
When a bucket exceeds its configured maximum throughput limit, subsequent requests assigned to that bucket can receive HTTP 429 with substatus code 3212.
This substatus helps distinguish bucket-limit throttling from other causes of HTTP 429 responses.
For example, a background import may reach its 10% limit while the container still has available throughput for other workloads. The import requests can be throttled even though the container has not exhausted its overall capacity.
The Azure Cosmos DB SDK provides retry behavior for throttled requests. However, developers should still monitor retry activity and end-to-end latency. A request that eventually succeeds after several retries can still affect the user experience or delay a background job.
HTTP 429 with substatus 3213
Throughput bucket configuration changes are subject to a separate restriction. The configuration can be modified once every 10 minutes. More frequent changes can result in HTTP 429 with substatus code 3213.
Avoid repeatedly changing bucket percentages during normal application execution. Treat bucket configuration as an operational setting that should be adjusted deliberately.
Invalid bucket IDs
Only bucket IDs from 1 through 5 are valid. Using an ID outside this range results in an error.
Centralize bucket IDs in configuration or constants rather than accepting arbitrary values from users or external requests.
Deleted bucket IDs
If a valid bucket is deleted, requests that still reference that ID do not necessarily fail. They fall back to consuming the container's overall throughput instead of using the deleted bucket's limit.
This behavior is important during configuration changes. Before removing a bucket, identify all applications and services that still assign requests to it.
Limitations and Important Considerations
Throughput buckets are useful for workload governance, but they do not apply to every Azure Cosmos DB configuration.
Important limitations include:
- Throughput buckets apply to Azure Cosmos DB for NoSQL.
- They are not supported for serverless accounts.
- They are not supported for containers in a shared-throughput database.
- A container supports up to five buckets.
- Bucket IDs are numeric and range from 1 to 5.
- Throughput is not reserved for individual buckets.
- Bucket configuration changes are limited to once every 10 minutes.
- Requests using a deleted valid bucket ID fall back to the container's overall throughput.
There are also operational considerations. A bucket with a low maximum can delay a workload that suddenly needs to process more data. A bucket with a high maximum may provide less protection to other workloads than expected.
For this reason, test the configuration under realistic traffic conditions before using it in a production environment.
Common Mistakes to Avoid
Treating bucket percentages as reserved capacity
A bucket's maximum percentage is a consumption cap, not a guaranteed allocation. Do not design application performance expectations around reserved RU/s that the feature does not provide.
Assigning all workloads to the same bucket
If every service uses one bucket, the application may not achieve the workload separation it needs. Group workloads according to their business purpose and resource requirements.
Creating too many buckets
A container supports a maximum of five buckets. Use them for meaningful workload categories rather than creating separate buckets for every endpoint or application instance.
Ignoring the default bucket
Requests without an explicit assignment can use the configured default bucket. If no default is configured, they use the container's throughput without a bucket-specific limit.
Review this behavior when introducing the feature to existing applications.
Ignoring SDK versions
Older SDK versions may not support the required throughput bucket options. Verify the minimum supported version before changing application code.
Treating HTTP 429 as an application failure
A 429 response can indicate that a bucket has reached its configured limit. Investigate the substatus code and request diagnostics before changing the container's overall throughput.
Changing bucket configuration too frequently
Repeated configuration updates within the 10-minute restriction can produce additional 429 responses with substatus 3213. Make configuration changes through a controlled operational process.
Best Practices for Production Applications
A good throughput bucket strategy should protect important workloads without unnecessarily delaying background processing.
- Identify workloads according to business priority before creating buckets.
- Use dedicated buckets for large imports, migrations, and background processing.
- Keep customer-facing workloads separate from resource-intensive background jobs where appropriate.
- Use client-level assignment when an application client performs a single workload.
- Use request-level assignment when one service handles multiple workload categories.
- Configure a default bucket when unclassified traffic needs a consumption limit.
- Keep bucket IDs in centralized configuration or constants.
- Monitor RU consumption and request counts by bucket.
- Track HTTP 429 responses and distinguish substatus 3212 from other throttling causes.
- Measure application latency and background job completion time.
- Test configuration changes with realistic traffic before production rollout.
- Review all application clients before disabling or deleting a bucket.
- Remember that throughput buckets do not replace partition-key design, indexing, or application-level rate limiting.
Advantages and Disadvantages of Throughput Buckets
| Advantages | Disadvantages |
|---|
| Provides workload-level throughput limits within a container | Does not reserve throughput for individual workloads |
| Helps control bulk imports and background processing | A heavily limited bucket can delay its assigned workload |
| Allows different applications to share the same data | Requests must be assigned to the correct bucket |
| Reduces the need to separate workloads into different containers in some scenarios | Supports a maximum of five buckets per container |
| Provides bucket-level metrics for monitoring | Requires careful configuration and operational monitoring |
| Supports client-level and request-level assignment in supported SDKs | Not supported for serverless accounts or shared-throughput database containers |
Summary
Azure Cosmos DB throughput buckets provide a way to control how much throughput different workloads can consume within a shared container. They are particularly useful for applications that combine customer-facing requests with background imports, migrations, synchronization, and other resource-intensive operations.
The feature works by assigning requests to numeric buckets and applying a maximum throughput percentage to each enabled bucket. Developers can configure these assignments at the client or request level using supported Azure Cosmos DB SDK versions.
The most important design consideration is that throughput buckets provide consumption limits, not reserved capacity. They do not increase the container's total RU/s or guarantee a fixed amount of throughput for another workload.
For production applications, combine bucket configuration with RU monitoring, latency tracking, retry diagnostics, and realistic load testing. When used with a clear workload-isolation strategy, throughput buckets can help protect important application operations while keeping related data in the same Azure Cosmos DB container.
Join the conversation! Your thoughts help the community grow.