Skip to content

Conversation

@dfawley
Copy link
Member

@dfawley dfawley commented Jul 8, 2025

See b/412468630, and esp. comment 46. Essentially, if the connection order is not randomized then the first address gets hammered with all the client's initial requests when traffic is bursty. If multiple clients are all using the same order and many start up around the same time, then the first address can see that problem magnified even further. Randomizing at least spreads the load between the clients, even if it still results in one address getting hammered at startup.

The diffs are much smaller than it shows. Basically, the existing e.s._test.go was moved to ..._ext_test.go and the only new code is in ..._test.go. _ext_test.go is completely unchanged from the old _test.go. Weightedtarget's tests needed changes because they assumed the order in which subchannels were created matched the order in which endpoints were provided.

RELEASE NOTES:

  • round_robin: randomize the order in which addresses are connected to in order to spread out initial RPC load between clients.
@dfawley dfawley added this to the 1.75 Release milestone Jul 8, 2025
@dfawley dfawley requested a review from eshitachandwani July 8, 2025 21:24
@dfawley dfawley added the Type: Feature New features or improvements in behavior label Jul 8, 2025
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.32%. Comparing base (64a6b62) to head (4fdc848).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8438      +/-   ##
==========================================
- Coverage   82.34%   82.32%   -0.03%     
==========================================
  Files         414      414              
  Lines       40411    40433      +22     
==========================================
+ Hits        33276    33286      +10     
- Misses       5771     5781      +10     
- Partials     1364     1366       +2     
Files with missing lines Coverage Δ
balancer/endpointsharding/endpointsharding.go 93.71% <100.00%> (+0.38%) ⬆️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

// rotateEndpoints returns a slice of all the input endpoints rotated a random
// amount.
func rotateEndpoints(es []resolver.Endpoint) []resolver.Endpoint {
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this actually changes the order of the address list, rather than simply starting to connect from a random index. But maybe that amounts to the same thing, since each new picker starts from a random index anyway in RR?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function rotates the slice a random amount -- it puts all elements after the random point at the start of a new slice, and the elements before it at the end.

}

// The sc# corresponding to addr3 is not known due to possible randomization
// in connection order in RR. Check the address instead of sc and set
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly , we have changed sc3 to correspond to address 3 in the above change. I am not sure what this comment accomplishes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I changed the way I did this and left this comment from the old way behind. Removed

@dfawley dfawley merged commit b64eaf8 into grpc:master Jul 14, 2025
23 of 24 checks passed
@dfawley dfawley deleted the rrrand branch July 14, 2025 22:29
dimpavloff pushed a commit to dimpavloff/grpc-go that referenced this pull request Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New features or improvements in behavior

3 participants