Skip to content
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

ThroughputBucketing: Adds Throughput Bucket to RequestOptions and ClientOptions #4940

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Achint-Agrawal
Copy link
Contributor

@Achint-Agrawal Achint-Agrawal commented Dec 27, 2024

Description

This PR add ThroughputBucket in RequestOptions and ClientOptions to support Throughput Bucketing

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

All good!

@Achint-Agrawal Achint-Agrawal changed the title Added Throughput Bucket to RequestOptions and ClientOptions [Internal] Category:Adds Added Throughput Bucket to RequestOptions and ClientOptions Dec 27, 2024
@Achint-Agrawal Achint-Agrawal changed the title [Internal] Category:Adds Added Throughput Bucket to RequestOptions and ClientOptions [Internal] Category:Adds Throughput Bucket to RequestOptions and ClientOptions Dec 27, 2024
@Achint-Agrawal Achint-Agrawal changed the title [Internal] Category:Adds Throughput Bucket to RequestOptions and ClientOptions ThroughputBucketing:Adds Throughput Bucket to RequestOptions and ClientOptions Dec 27, 2024
@Achint-Agrawal Achint-Agrawal changed the title ThroughputBucketing:Adds Throughput Bucket to RequestOptions and ClientOptions ThroughputBucketing: Adds Throughput Bucket to RequestOptions and ClientOptions Dec 27, 2024
/// If <see cref="AllowBulkExecution"/> is set to true in CosmosClientOptions, throughput bucket set on the CosmosClient is used.
/// </remarks>
/// <seealso href="https://aka.ms/cosmsodb-bucketing"/>
public int? ThroughputBucket { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Is an int the only possible way to identify a throughput bucket or can names/identifiers be also used? The int/number seems like it will cause confusion for customers easily.

Copy link
Member

Choose a reason for hiding this comment

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

How is this feature rolled-out? If there is any opt-in necessary on the service side in .Net SDK this should only be released in the preview nuget package first - and at least the PR description should have clear instructions for onboarding. If the feature is just enabled automatically for all accounts we can add this as public API assuming we have confidence in the public API in the normal nuget packaage (assuming all deployements including non-public clouds have been finished to enable the backend feature)

/// </summary>
/// <remarks>
/// If throughput bucket is also set at request level in <see cref="RequestOptions.ThroughputBucket"/>, that throughput bucket is used.
/// If <see cref="WithBulkExecution(bool)"/> is set to true, throughput bucket set on the CosmosClient is used.
Copy link
Member

Choose a reason for hiding this comment

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

Why this constraint? That seems super confusing. I get what you are saying - if bulk mode is enabled and request options have different values this is a challenge in .Net - but why not throw an ArgumentException if request options has throughput bucket defined and bulk mode is enabled - that way the contract is enforced cleanly

Copy link
Member

Choose a reason for hiding this comment

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

+1 to throw and fail.

@@ -940,6 +940,16 @@ public IFaultInjector FaultInjector
}
}

/// <summary>
Copy link
Member

Choose a reason for hiding this comment

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

Please also add an aka.ms link to explain the concept and constraints of throughput buckets

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.

Thanks - overall changes look good. Mainly blocking on clarification for versioning/rollout/onboarding.


if (options.ThroughputBucket.HasValue)
{
headers.Set(HttpConstants.HttpHeaders.ThroughputBucket, options.ThroughputBucket.ToString());
Copy link
Member

Choose a reason for hiding this comment

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

I know we only support a small number of buckets, but we should really specify a format here to not have something like thousands separators vary by client locale settings.

/// Set the ThroughputBucket in the request headers
/// </summary>
/// <param name="requestMessage"></param>
private void SetThroughputBucket(RequestMessage requestMessage)
Copy link
Member

Choose a reason for hiding this comment

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

[Non blocker]
Our RequestOptions are stateless but pattern of overrides implementation in RequestInvokerHandler is odd.
One alternative way is to pass the CosmosClientOptions along with ReqeustMessge for RequestOptions.RequestOptions?

/cc: @FabianMeiswinkel thoughts?

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

Successfully merging this pull request may close these issues.

4 participants