Skip to content

AddThroughputBucketSupport #46042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

xinlian12
Copy link
Member

@xinlian12 xinlian12 commented Jul 16, 2025

Description

Added throughput bucket support

Public API

Using throughput bucket only:

        ThroughputControlGroupConfig groupConfig =
            new ThroughputControlGroupConfigBuilder()
                .groupName("group-" + UUID.randomUUID())
                .throughputBucket(1)
                .build();
        container.enableServerThroughputControlGroup(groupConfig);

Using priorityLevel only:

        ThroughputControlGroupConfig groupConfig =
            new ThroughputControlGroupConfigBuilder()
                .groupName("group-" + UUID.randomUUID())
                .priorityLevel(PriorityLevel.LOW)
                .build();
        container.enableServerThroughputControlGroup(groupConfig);

Using priorityLevel and throughputBucket together:

        ThroughputControlGroupConfig groupConfig =
            new ThroughputControlGroupConfigBuilder()
                .groupName("group-" + UUID.randomUUID())
                .priorityLevel(PriorityLevel.LOW)
                .throughputBucket(1)
                .build();
        container.enableServerThroughputControlGroup(groupConfig);

UML

(Note: LocalThroughputControlGroupController & GlobalThroughputControlGroupController are removed from the graph for simplicity)

image

Sequence flow

Throughput control store flow:
image

SDK Throughput control store flow:
image

Server Throughput control store flow:
image

Diagnostics:

New requestTCG and requestTCGConfig added:
image

E2E testing:

image

Copy link
Contributor

github-actions bot commented Jul 16, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-cosmos

@@ -598,7 +598,8 @@ public enum RntbdRequestHeader implements RntbdHeader {
SDKSupportedCapabilities((short) 0x00A2, RntbdTokenType.ULong, false),
ChangeFeedWireFormatVersion((short) 0x00B2, RntbdTokenType.String, false),
PriorityLevel((short) 0x00BF, RntbdTokenType.Byte, false),
GlobalDatabaseAccountName((short) 0x00CE, RntbdTokenType.String, false);
GlobalDatabaseAccountName((short) 0x00CE, RntbdTokenType.String, false),
ThroughputBucket((short)0x00DB, RntbdTokenType.Byte, false); //TODO: does the throughput bucket supported in thin client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thin client is a good question. Also GAteway mode is relevant - we would rely on ComputeGateway and Routing Gateway to pass through the header. I would expect this to work in thin client because the rntbd body is passed through opaquely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will double check the behavior here

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for the well structured API and the great PR description - really helped to review the PR!

@xinlian12 xinlian12 force-pushed the addThroughputBucketSupport branch from fa8285b to c965815 Compare July 29, 2025 05:42
@xinlian12 xinlian12 marked this pull request as ready for review July 29, 2025 06:05
@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 06:05
@xinlian12 xinlian12 requested review from kirankumarkolli and a team as code owners July 29, 2025 06:05
@xinlian12 xinlian12 changed the title AddThroughputBucketSupport - [NO REVIEW] AddThroughputBucketSupport Jul 29, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces throughput bucket support to the Azure Cosmos DB Java SDK, enabling server-side throughput control functionality. The key change is adding support for throughput buckets alongside the existing priority level controls, with a new API for enabling server throughput control groups.

Key changes:

  • Adds throughput bucket support to ThroughputControlGroupConfig and related APIs
  • Introduces server throughput control store and controllers for bucket-based throughput management
  • Refactors existing SDK throughput control classes into a dedicated sdk package structure
  • Adds comprehensive test coverage for the new server throughput control functionality

Reviewed Changes

Copilot reviewed 80 out of 80 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ThroughputControlGroupConfig.java Adds throughput bucket field and getter method
ThroughputControlGroupConfigBuilder.java Adds throughput bucket setter with validation
CosmosAsyncContainer.java Adds enableServerThroughputControlGroup method
Server throughput control classes New implementation for server-side throughput bucket control
SDK throughput control refactor Moves existing SDK throughput control to dedicated package
Test files Comprehensive test coverage for new functionality
Comments suppressed due to low confidence (2)

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/throughputControl/sdk/ThroughputRequestThrottler.java:23

  • Unused import statement should be removed. The UUID import is not used anywhere in this file.
import java.util.concurrent.ConcurrentHashMap;

@@ -598,7 +598,8 @@ public enum RntbdRequestHeader implements RntbdHeader {
SDKSupportedCapabilities((short) 0x00A2, RntbdTokenType.ULong, false),
ChangeFeedWireFormatVersion((short) 0x00B2, RntbdTokenType.String, false),
PriorityLevel((short) 0x00BF, RntbdTokenType.Byte, false),
GlobalDatabaseAccountName((short) 0x00CE, RntbdTokenType.String, false);
GlobalDatabaseAccountName((short) 0x00CE, RntbdTokenType.String, false),
ThroughputBucket((short)0x00DB, RntbdTokenType.Byte, false); //TODO: does the throughput bucket supported in thin client
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment should be resolved or moved to a proper issue tracker. Comments like this should not remain in production code.

Suggested change
ThroughputBucket((short)0x00DB, RntbdTokenType.Byte, false); //TODO: does the throughput bucket supported in thin client
ThroughputBucket((short)0x00DB, RntbdTokenType.Byte, false); // Throughput bucket is supported in thin client

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove this comment later once confirmed the behavior

* Get the throughput bucket.
* <p>
* For more information about throughput bucket please visit
* <a href="https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/throughput-buckets?tabs=dotnet">Throughput buckets in Azure Cosmos DB</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc should be extended for Java (min sdk versiona nd how to use the feature - would be better to refernece the java sample than .net - but can be done in separate PR)

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants