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

Listener: respect the connection balancer of the redirected listener #15842

Merged
merged 23 commits into from
Apr 29, 2021

Conversation

lambdai
Copy link
Contributor

@lambdai lambdai commented Apr 5, 2021

Commit Message:
If listener1 redirects the connection to listener2, the balancer field in listener2 decides whether to rebalance.
Previously we rely on the rebalancing at listener1, however, the rebalance is weak because listener1 is likely to
not own any connection and the rebalance is no-op.

Additional Description:
on top of #15815
merged main branch

Risk Level: MID. Rebalance may introduce latency. User needs to clear rebalancer field of listener2 to recover the original behavior.
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
Fix #15146 #16113
[Optional Deprecated:]
[Optional API Considerations:]

lambdai added 8 commits April 1, 2021 10:28
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
lambdai added 3 commits April 7, 2021 11:54
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai lambdai marked this pull request as ready for review April 8, 2021 06:42
@dmitri-d
Copy link
Contributor

dmitri-d commented Apr 9, 2021

To see if I got the issue right:

listener1 connection count is low, it gets a connection. Then, in newConnection(), a new handler is picked based on the original destination address. Becase hand_off_restored_destination_connections and rebalanced are false and true respectively, this becomes the ultimate handler of the connection, regardless of the number of connections it's already handling.

If the above is accurate, then your changes lgtm, but I'll need to take a better look at tests.

@lambdai
Copy link
Contributor Author

lambdai commented Apr 9, 2021

listener1 connection count is low, it gets a connection.

Thanks @dmitri-d! The linked #15146 has more details regarding listener1. In some cases including istio, the listener1(virtual outbound in istio) doesn't own any connection after the redirect.

Now that the accounting is bad, it's likely all the workers of listener1 will always rebalance the connection to worker0's listener1...

@dmitri-d
Copy link
Contributor

the test lgtm too.

@lambdai
Copy link
Contributor Author

lambdai commented Apr 12, 2021

gentle ping @ggreenway

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

I think this will be fine. I've never looked at the rebalancer code before, but I think I've familiarized myself with it. @mattklein123 do you want to take a quick look for sanity at the main code change and make sure this makes sense to you?

I think this would benefit from an integration test, verifying that multiple levels of balancing end up with the correct result.

Also, is there a good place to document that the exact-rebalancer should not be used in these use cases? I think it's just extra overhead without any benefit.

test/mocks/network/mocks.h Outdated Show resolved Hide resolved
test/mocks/network/mocks.h Show resolved Hide resolved
@mattklein123 mattklein123 self-assigned this Apr 13, 2021
@mattklein123
Copy link
Member

Yeah this seems fine to me at a high level. 👍

@mattklein123 mattklein123 removed their assignment Apr 13, 2021
test/server/active_tcp_listener_test.cc Show resolved Hide resolved
test/mocks/network/mocks.h Outdated Show resolved Hide resolved
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai
Copy link
Contributor Author

lambdai commented Apr 15, 2021

/wait

lambdai added 3 commits April 23, 2021 14:07
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
lambdai added 3 commits April 23, 2021 20:59
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
envoyproxy/api-shepherds assignee is @htuch
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #15842 was synchronize by lambdai.

see: more, trace.

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai lambdai mentioned this pull request Apr 26, 2021
@lambdai lambdai requested a review from ggreenway April 26, 2021 20:06
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait

api/envoy/config/listener/v3/listener.proto Outdated Show resolved Hide resolved
test/integration/listener_lds_integration_test.cc Outdated Show resolved Hide resolved
test/integration/listener_lds_integration_test.cc Outdated Show resolved Hide resolved
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@ggreenway
Copy link
Contributor

@htuch can you sign off on the api change?

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

/lgtm api

@htuch htuch merged commit 3e96780 into envoyproxy:main Apr 29, 2021
@lambdai lambdai deleted the rebalancer branch April 29, 2021 18:35
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
…nvoyproxy#15842)

If listener1 redirects the connection to listener2, the balancer field in listener2 decides whether to rebalance.
Previously we rely on the rebalancing at listener1, however, the rebalance is weak because listener1 is likely to
not own any connection and the rebalance is no-op.

Risk Level: MID. Rebalance may introduce latency. User needs to clear rebalancer field of listener2 to recover the original behavior.

Fix envoyproxy#15146 envoyproxy#16113

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Gokul Nair <gnair@twitter.com>
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
…nvoyproxy#15842)

If listener1 redirects the connection to listener2, the balancer field in listener2 decides whether to rebalance.
Previously we rely on the rebalancing at listener1, however, the rebalance is weak because listener1 is likely to
not own any connection and the rebalance is no-op.

Risk Level: MID. Rebalance may introduce latency. User needs to clear rebalancer field of listener2 to recover the original behavior.

Fix envoyproxy#15146 envoyproxy#16113

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Signed-off-by: Gokul Nair <gnair@twitter.com>
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.

listener: performance degradation when exact balance used with original dst
6 participants