Today, we’re excited to announce the general availability of throughput buckets in Azure Cosmos DB for NoSQL. You can now set workload-level throughput limits within a shared container, so background work has a clear boundary without requiring a separate copy of your data.
The challenge: competing workloads in one container
A container often serves several workloads at once: user-facing queries, requests from different customer tiers, and background jobs such as bulk imports, migrations or exploratory queries. Without workload-level controls, they all compete for the same throughput, and any of them can be throttled during contention.
Increasing the container’s RU/s adds capacity but puts no boundary around any one workload’s consumption. Moving each workload to a separate container introduces data synchronization and extra application logic.
The question is not just, “How much throughput does this container need?” It is also, “How much should each workload be allowed to consume?”
How throughput buckets work
Throughput buckets let you assign requests to a bucket and cap the percentage of container throughput that bucket can consume. Azure Cosmos DB enforces the limit on the bucket’s combined traffic, so individual application instances don’t need to limit themselves.
- Shared throughput: All traffic assigned to a bucket share that bucket’s throughput.
- Caps, not reservations: An idle workload does not hold throughput aside, and capping one bucket does not reserve the remaining capacity for another. The container’s capacity remains shared.
- Observable throttling: When a bucket reaches its cap, further requests to it are throttled with HTTP 429 and substatus 3212, to distinguish bucket-limit throttling from other causes.
See it in action: Contoso Marketplace
Consider Contoso, a retail marketplace where sellers list products. Standard-tier users and paid Premium-tier users search the same catalog, while background bulk jobs update it. Contoso wants to give Premium users a better search experience, while continue serving the free Standard tier, and run bulk jobs at a controlled pace.
Contoso configures two buckets:
| Bucket ID | Workload description | Maximum percentage |
| 1 | Background bulk jobs | 10% |
| 2 | Standard-tier product searches | 40% |
Standard-tier users share bucket 2’s 40% throughput cap. Premium searches are sent without a bucket, so they have no bucket-specific ceiling below the container’s limit.
Bulk execution job uses bucket 1 with 10% max cap.
Common usage patterns
Use throughput buckets whenever you need to cap the throughput that one or more workloads can consume. Common scenarios include:
- Multi-tenant SaaS applications: Cap throughput per service tier so premium-tier tenants get better performance.
- Migrations alongside live traffic: Use a client-level bucket for the bulk requests that move data.
- Change-feed processing: Put projection writes in a bucket on the destination container. Source reads and destination writes are limited separately.
- Interactive investigations: Data Explorer queries run in bucket 1 when it is configured, set bucket 1’s maximum cap to limit their impact on production workloads.
Set up throughput buckets
In the Azure portal:
- Open your Azure Cosmos DB account and select Data Explorer.
- Select your container and open Scale & Settings.
- Open Throughput Buckets.
- Change the buckets you want to use from Inactive to Active.
- Set each bucket’s maximum throughput percentage and save the configuration.
Use buckets in your code
Once buckets are active, you can assign a bucket per request or per client, or rely on a container default for everything else.
Assign a bucket to individual requests
Assign buckets per request when a single service serves several tenant tiers. Contoso’s search service sends Standard-tier queries to bucket 2 and leaves Premium-tier queries unassigned.
Both searches hit the same container. Setting ThroughputBucket to 2 places Standard searches under the 40% cap, while a null value leaves Premium searches without a bucket assignment.
using CosmosClient client = new(
"<account-endpoint>", new DefaultAzureCredential());
Container products = client.GetContainer("Retail", "Products");
await Task.WhenAll(
SearchProductsAsync(products, "Standard", 2),
SearchProductsAsync(products, "Premium", null));
static async Task SearchProductsAsync(
Container products, string tier, int? bucket)
{
QueryDefinition query = new QueryDefinition(
"SELECT * FROM c WHERE c.categoryId = @categoryId")
.WithParameter("@categoryId", "shoes");
using FeedIterator<Product> results =
products.GetItemQueryIterator<Product>(
query,
requestOptions: new QueryRequestOptions
{
PartitionKey = new PartitionKey("shoes"),
ThroughputBucket = bucket
});
while (results.HasMoreResults)
{
FeedResponse<Product> page = await results.ReadNextAsync();
Console.WriteLine(
$"{tier}: {page.Count} products, {page.RequestCharge} RU");
}
}
public record Product(
string id, string categoryId, string name, decimal price);
Assign a bucket to a client for bulk ingestion
Now implement Contoso’s background bulk workload: a supplier import in bucket 1 at 10%. Every product this worker writes belongs to one workload, so assign bucket 1 when creating the client and enable bulk execution.
using CosmosClient bulkClient = new(
"<account-endpoint>",
new DefaultAzureCredential(),
new CosmosClientOptions
{
AllowBulkExecution = true,
ThroughputBucket = 1
});
Container products = bulkClient.GetContainer("Retail", "Products");
using FileStream file = File.OpenRead("supplier-products.json");
List<Product> supplierProducts =
await JsonSerializer.DeserializeAsync<List<Product>>(file)
?? throw new InvalidDataException("The product file is empty.");
foreach (Product[] batch in supplierProducts.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);
Use a default bucket for requests without an assignment
Explicit tagging works well for code you control, but applications often include older services or occasional tools that do not specify a bucket.
As a separate extension to the two-bucket example, activate bucket 5 at 15% and mark it as the container’s default throughput bucket in Data Explorer. Unassigned traffic will then share that ceiling.
There are two different defaults to keep in mind:
- Client assignment: Supplies a bucket for requests created by that SDK client. For supported non-bulk operations, an explicit request-level bucket takes precedence.
- Container default: Applies when the request arrives without a bucket assignment.
Without an active default, unassigned requests have no bucket-specific cap.
Monitor usage and tune the limits
In your account’s Metrics pane:
- Filter to the database and container you are managing.
- Select Total Requests (Preview) and split by ThroughputBucket to compare request counts.
- Select Total Request Units (Preview) and split by ThroughputBucket to compare RU consumption.
- Filter request metrics by StatusCode = 429 to identify throttled traffic.
Capture 3212 in application diagnostics to identify a bucket cap specifically. Azure Cosmos DB SDKs can retry throttled requests, so also monitor end-to-end latency and failures returned after retries.
Important considerations
- Throughput buckets are for Azure Cosmos DB for NoSQL and are not supported on serverless accounts or containers using shared database throughput.
- A container supports up to five buckets, with numeric IDs 1 through 5, not custom service-side names.
- Bucket configurations can be changed once every 10 minutes. More frequent updates receive HTTP 429 with substatus 3213.
- Requests using a deleted valid bucket ID fall back to overall container throughput. IDs outside 1 through 5 are invalid. Review callers before removing a bucket.
Next steps
Start with the workload you most want to constrain: a supplier import, a migration, or a background maintenance job. Configure its bucket, assign its requests or client, and compare application latency and job progress before tuning the cap.
Then add a default bucket for unassigned traffic and make bucket usage part of your monitoring dashboard. You can introduce workload-level control without separating data that belongs together.
Learn more in the throughput buckets documentation and throughput buckets FAQ and find samples here.
About Azure Cosmos DB
Azure Cosmos DB is a fully managed NoSQL and vector database for modern applications, including AI apps. With SLA-backed performance and availability, automatic scaling, and global distribution, it helps developers build fast, reliable applications.
Find more developer resources at the Azure Cosmos DB developer hub.
Stay connected with Azure Cosmos DB on X, YouTube, and LinkedIn.
0 comments
Be the first to start the discussion.