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

[Internal] Parallel Hedging: Adds Docs #4082

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

NaluTripician
Copy link
Contributor

Pull Request Template

Description

Please include a summary of the change and which issue is fixed. Include samples if adding new API, and include relevant motivation and context. List any dependencies that are required for this change.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

If you want to change the preferred regions for a `CosmosClient` you can do so by callinga new method.

```csharp
client.UpdatePreferredRegions(new List<string>() { "West US", "East US" });
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Making this mutable is risky - in Java we have instead allowed specifying excluded regions (and made that mutable) as well as configurable per request options. Achieves the same - but hasn't the same implications of making preferred regions mutable everywhere

```csharp
CosmosClientOptions options = new CosmosClientOptions()
{
SpeculativeProcessor = new ThresholdSpeculator(TimeSpan.FromMilliseconds(500))
Copy link
Member

Choose a reason for hiding this comment

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

Is SpeculativeProcessor a public contract CX can add/extend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might be better to have it be a private contract here. I will make it so it's only a private contract.

The example above will create a `CosmosClient` instance with speculative processing enabled with at 500ms threhshold. This means that if a request takes longer than 500ms the SDK will send a new request to the backend in order of the Preferred Regions List. This process will repeat until a request comes back. The SDK will then return the first response that comes back from the backend. The threshold parameter is a required parameter can can be set to any value greater than 0. There are also methods that will allow a user to disable/enabled speculative processing after the client has been created. If you include speculative processing when creating the client it will be enabled by default.

```csharp
client.DisableSpeculativeProcessing(); // Disables speculative processing
Copy link
Member

Choose a reason for hiding this comment

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

Request level granular is also one ASK.
Assuming if we have that then are these APIs at Client scope still necessary?

Copy link
Member

Choose a reason for hiding this comment

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

+1 requestOptions level override definitely is needed - especially for queries (but not just)

```csharp
RequestOptions requestOptions = new RequestOptions()
{
LocationToRouteTo = "West US"
Copy link
Member

Choose a reason for hiding this comment

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

Will it be a single Region or Equivalent to PReferredRegions?

Copy link
Member

Choose a reason for hiding this comment

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

Again - why do the opposite of Java (we used excluded regions here) - region to route to as an override owuld allow routing to a region which is not even in preferred regions?

I think it just opens a can of worms


```csharp
CosmosClient client = new CosmosClientBuilder("connection string")
.WithSpeculativeProcessing(type: SpeculationType.Threshold, speculativeThreshold: TimeSpan.FromMilliseconds(500))
Copy link
Member

Choose a reason for hiding this comment

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

Remove Speculative/Speculation term everywhere

This has burned us already with Walmart - for customers "speculation" sounds too random. In Java we have used the term ThresholdBasedAvailabilityStartegy or something along those lines.

Copy link
Member

Choose a reason for hiding this comment

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

Like here
WithAvailabilityStrategy(AvailabilityStartegyType.Threshold) or such

```csharp
CosmosClientOptions options = new CosmosClientOptions()
{
RegionConsistencyLevel = new ObservableCollection<string, ConsistencyLevel>()
Copy link
Member

Choose a reason for hiding this comment

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

Wow - why is this needed?


This will override any logic the SDK does to determine where to route requests and will route the request to the region specified in the `LocationToRouteTo` property.

## Region Specific Conistency Levels
Copy link
Member

Choose a reason for hiding this comment

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

I would be really curious why we would want to add this to public API ?

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.

As discussed - public API has too many inconsistencies with Java that have been discussed before and are pitfalls.

```csharp
RequestOptions requestOptions = new RequestOptions()
{
AvailabilityStrategyFallbackConsistencyLevel = ConsistencyLevel.Eventual
Copy link
Member

Choose a reason for hiding this comment

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

This can be encapsulated by AvailabilityStrategyOptions as well right? Also, what are the consistency override semantics here - availability strategy level config overrides request level config overrides client level config?

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