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

Gateway: Adds optimization to reduce gateway header size by scoping session token to specific partitions. #2165

Merged
merged 21 commits into from
Mar 29, 2021

Conversation

asketagarwal
Copy link
Contributor

@asketagarwal asketagarwal commented Jan 29, 2021

Pull Request Template

Description

Currently in Gateway Mode, the entire session token from all Partitions is sent to the backend. With this change we try to resolve the partition of the request before sending to gateway and send only that session token. This will solve the issue of large headers leading to 400 errors.
We first try to resolve the partition from PartitionKeyRangeCache. If we can't, we refresh the cache. If we still can't we send the GlobalSessionToken.

Issue No: closes #2146

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.

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"

Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

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.

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"

Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@asketagarwal asketagarwal changed the title Session Token Optimization for Gateway Mode. [Internal] Gateway: Session Token Optimization for Gateway Mode. Jan 29, 2021
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.

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"

Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@asketagarwal asketagarwal changed the title [Internal] Gateway: Session Token Optimization for Gateway Mode. [Internal] Gateway: Add Session Token Optimization for Gateway Mode. Jan 29, 2021
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.

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"

Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@asketagarwal asketagarwal changed the title [Internal] Gateway: Add Session Token Optimization for Gateway Mode. [Internal] Gateway: Adds Session Token Optimization for Gateway Mode. Jan 29, 2021
@github-actions github-actions bot dismissed stale reviews from themself January 29, 2021 14:52

All good!

@j82w j82w changed the title [Internal] Gateway: Adds Session Token Optimization for Gateway Mode. Gateway: Adds Session Token Optimization for Gateway Mode. Feb 1, 2021
ealsur
ealsur previously approved these changes Mar 16, 2021
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

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

Left some nits, would be good to do a manual split test

Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs Outdated Show resolved Hide resolved
Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs Outdated Show resolved Hide resolved
Microsoft.Azure.Cosmos/src/GatewayStoreModel.cs Outdated Show resolved Hide resolved
j82w
j82w previously approved these changes Mar 22, 2021
Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

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

Please close on the batch part before merging.

/cc: @j82w

@asketagarwal asketagarwal dismissed stale reviews from kirankumarkolli, j82w, and ealsur via 13474de March 23, 2021 13:08
@j82w j82w changed the title Gateway: Adds Session Token Optimization for Gateway Mode. Gateway: Adds optimization to reduce gateway header size by scoping session token to specific partitions. Mar 29, 2021
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

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

Thanks for testing splits

@j82w j82w merged commit 42e597c into master Mar 29, 2021
@j82w j82w deleted the users/askagarw/SessionTokenOptimisation branch March 29, 2021 19:59
j82w pushed a commit that referenced this pull request Jun 11, 2021
This was introduced in PR #2165

The issue is when one client deletes and recreates a container, any request on another client gives a NullReferenceException.
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.

Optimize gateway session token logic
4 participants