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

A76: Improvements to the Ring Hash LB Policy #412

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

Conversation

atollena
Copy link
Contributor

@atollena atollena commented Jan 22, 2024

Based on discussion in grpc/grpc#33356.

A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth 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 writing this!

Overall, the design looks good, but I think there is one significant issue related to where we compute the request hash, since I don't think it will work to do it in the picker. That will probably need a bit more discussion to resolve.

Please let me know if you have any questions. Thanks!

A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth 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 making those updates! We'll get back to you on the open question once Eric gets back.

A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
@atollena
Copy link
Contributor Author

@markdroth just checking in on this, I've made the updates regarding handling the empty header. I'll start testing an implementation for this internally, but in the meantime would appreciate another review. Thanks!

Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! This looks really good overall. Comments are mostly things to improve clarity of the doc.

Please let me know if you have any questions. Thanks!

A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Show resolved Hide resolved
A76-ring-hash-improvements.md Show resolved Hide resolved
A76-ring-hash-improvements.md Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

This looks great to me!

@ejona86 @dfawley Would you two please do a review pass as well? Thanks!

A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Show resolved Hide resolved
// Determine request hash.
using_random_hash = false;
if (config.request_hash_header.empty()) {
request_hash = call_attributes.hash;
Copy link
Member

Choose a reason for hiding this comment

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

Can't this also be empty? In which case you'd use a random hash, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think the behavior is a bit confusing as it it, since if request_hash_header is empty, and the call attribute is not set because there is no xDS config selector to set it to a random value, then this would result in a fix hash that always routes to the same endpoint on the ring. I updated the logic and the text to pick a random hash in this case.

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 prefer to preserve our existing behavior in the xDS case, which is to fail the pick if the hash isn't set (see C-core impl). If we're using xDS and the hash is not set, then something is very wrong, and I think it's better to fail RPCs with a specific error message to make the problem obvious than it is to just distribute traffic randomly.

A76-ring-hash-improvements.md Show resolved Hide resolved
A76-ring-hash-improvements.md Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
A76-ring-hash-improvements.md Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on this review pass -- way too many things to review, and not enough time. :(

I like where we ended up on the resulting pseudo-code. My remaining comments here are mostly minor things.

Hopefully, we're very close to getting this merged!

A61-IPv4-IPv6-dualstack-backends.md Outdated Show resolved Hide resolved
```proto
message RingHashLoadBalancingConfig {
// (existing fields omitted)
string request_hash_header = 3;
Copy link
Member

Choose a reason for hiding this comment

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

Note when implementing this that the JSON form of this field will be requestHashHeader, so that's what the implementation should use.

@@ -221,9 +230,7 @@ considered the following alternative solutions:

## Implementation

Implemented in Go:
- Allow setting the request hash key: https://github.com/grpc/grpc-go/pull/7170
Copy link
Member

Choose a reason for hiding this comment

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

I think it's useful to link implementation PRs here. I would suggest putting this back.

// Set by the xDS config selector.
request_hash = call_attributes.hash;
} else {
using_random_hash = true;
Copy link
Member

Choose a reason for hiding this comment

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

As per my comment elsewhere, I think this case should fail the RPC, just as we do today.

first_index = ring.FindIndexForHash(request_hash);
requested_connection = false;
if !using_random_hash {
// Return based on A62 unchanged.
Copy link
Member

Choose a reason for hiding this comment

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

I think you mean A61, not A62.

// Determine request hash.
using_random_hash = false;
if (config.request_hash_header.empty()) {
request_hash = call_attributes.hash;
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 prefer to preserve our existing behavior in the xDS case, which is to fail the pick if the hash isn't set (see C-core impl). If we're using xDS and the hash is not set, then something is very wrong, and I think it's better to fail RPCs with a specific error message to make the problem obvious than it is to just distribute traffic randomly.

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.

5 participants