Only detecting stale connections for UDP ports in kube-proxy#83208
Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom Oct 3, 2019
Merged
Conversation
The detectStaleConnections function in kube-proxy is very expensive in terms of CPU utilization. The results of this function are only actually used for UDP ports. This adds a protocol attribute to ServicePortName to make it simple to only run this function for UDP connections. For clusters with primarily TCP connections this can improve kube-proxy performance by 2x.
Contributor
|
/lgtm |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, robscott The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest Review the full test history for this PR. Silence the bot with an |
This was referenced Oct 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
The detectStaleConnections function in kube-proxy is very expensive in terms of CPU utilization. The results of this function are only actually used for UDP ports. This adds a protocol attribute to ServicePortName to make it simple to only run this function for UDP connections. For clusters with primarily TCP connections this can improve kube-proxy performance by 2x.
Special notes for your reviewer:
Sorry for the huge size of this PR. The actual functional code changes are rather small, but unfortunately the vast majority of tests did not specify a protocol, or if they did, it was inconsistently. To make this work I added protocol to the ServicePortName type. This resulted in fairly minimal changes to the codebase, but unfortunately resulted in lots of repetitive changes to tests that were rarely specifying a protocol.
I also considered allowing the EndpointChangeTracker to access the ServiceMap data structure, but that felt dirty and more bug prone. I also considered adding a new data structure to EndpointChangeTracker that would map ServicePortNames to their protocols. As far as I can tell, this would have required a similar amount of changes to tests as well unfortunately. Open to investigating that or other options if this feels too bad.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig network
/cc @freehan
/priority important-longterm