-
Notifications
You must be signed in to change notification settings - Fork 802
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
Connection retaining mode for p2p peer chooser #6471
Connection retaining mode for p2p peer chooser #6471
Conversation
9487ada
to
89e0870
Compare
16710bb
to
03318db
Compare
return c.Start() | ||
} | ||
|
||
return fmt.Errorf("failed to start direct peer chooser because direct peer chooser initialization failed, err: %v", g.legacyChooserErr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: %w
) | ||
|
||
const ( | ||
defaultGRPCSizeLimit = 4 * 1024 * 1024 | ||
factoryComponentName = "rpc-factory" | ||
) | ||
|
||
var ( | ||
// P2P outbounds are only needed for history and matching services | ||
servicesToTalkP2P = []string{service.History, service.Matching} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is frontend --> History not in scope? I can see a strong case for having frontend retain connections to history and matching instances as peers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think that worker might need need membership updates for the domain config stack (@Shaddoll can correct me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are sharded services that all other services communicate via p2p connections. RPC factory subscribes to membership updates of these services for that reason. Frontend and worker will still use this rpc factory and will be able to communicate with matching&history via p2p
What changed?
This PR is continuation of PR #6345 to complete implementation of custom peer chooser.
The custom chooser differs from yarpc's default "direct" chooser in how it handles connections. Direct chooser creates & releases p2p connections for each request.
The new peer chooser retains connections until the peer disappears from member list. Peers are added as needed basis (when a request is about to be made to a target peer).
There's going to be one peer chooser instance per target service which will cache active peers internally.
Only matching and history are such target services that all other services communicate p2p.
This is hidden behind feature flag
system.enableConnectionRetainingDirectChooser
and yarpc's direct peer chooser will still be used by default.Other changes:
Why?
Avoid unnecessary cost of recreating connections for each p2p request.
How did you test it?