Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

marseel
Copy link
Member

@marseel marseel commented Apr 30, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

Since P&F was introduced, we saw significant degradation of latency api calls. P&F was not the root cause, it was just contributing factor.
Currently, node leases are updated every 10s + latency call, which caused spikes to have slightly higher latency than api calls that were well distributed within 10s window. This causes spikes to move relatively within 10s window and accumulate other well distributed calls.
I've prepared metric that for each 100ms counts number of puts of leases and computes standard deviation for 10s window.
With default configuration, for 5k cluster, standard deviation was 10x bigger compared to build with this patch.
Also, number of updates of leases per 100 ms varied from 0 to 300 updates without this change, and with this change it was between 40 and 60.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added jitter factor to lease controller that better smears load on kube-apiserver over time.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 30, 2021
@k8s-ci-robot k8s-ci-robot requested review from deads2k and jpbetz April 30, 2021 08:46
@marseel
Copy link
Member Author

marseel commented Apr 30, 2021

/sig scalability
/assign @wojtek-t
/cc @mborsz

@k8s-ci-robot k8s-ci-robot added the sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. label Apr 30, 2021
@k8s-ci-robot k8s-ci-robot requested a review from mborsz April 30, 2021 08:48
return
}
wait.Until(c.sync, c.renewInterval, stopCh)
wait.JitterUntil(c.sync, c.renewInterval, 0.04, true, stopCh)
Copy link
Member

Choose a reason for hiding this comment

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

The alternative would be to use:

wait.NonSlidingUntil

[so that we don't move forward requests on spikes]

I don't have strong opinion either way, but we should ensure that we won't violate any assumptions:

  • Kubelet can definitely tolerate this
  • IIUC api-server should also be fine with this. @lavalamp - can you confirm?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering it, but preferred to stick to sliding. Assuming that function doesn't finish within 10s we could potentially call this function again, which might cause some race-condition. I am not the expert of this part of the code, but if non-sliding is safe here I am happy to change it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think using NonSlidingUntil will cause any race-condition. Rather, if the function takes > 10s, the next attempt will run immediately.

I think it's better to keep sliding:

  • if this function took long, but eventually succeeded, then it makes sense to wait the next 10s before we refresh the lease (it's fresh when the function ends)
  • if this function took long, but hasn't succeeded, it will technically make sense to retry, but I'm afraid that this may generate higher load on unhealthy master (instead of nodes refreshing statuses every 10s, we will have all nodes that are continuously inside of c.sync; the number of requests will depend on the actual backoff strategy there, but it will be still > 1qps/10s as we have with sliding).

Copy link
Member

Choose a reason for hiding this comment

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

I took a deeper look into kube-apiserver case and it is fine - even much larger jittering would work there.

The argument about retries for non-sliding case makes sense to me. So let's keep what we have now.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 30, 2021
@marseel
Copy link
Member Author

marseel commented Apr 30, 2021

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 30, 2021
@marseel
Copy link
Member Author

marseel commented Apr 30, 2021

/remove-kind feature

@k8s-ci-robot k8s-ci-robot removed the kind/feature Categorizes issue or PR as related to a new feature. label Apr 30, 2021
@marseel
Copy link
Member Author

marseel commented Apr 30, 2021

/retest

1 similar comment
@marseel
Copy link
Member Author

marseel commented Apr 30, 2021

/retest

@caesarxuchao
Copy link
Contributor

/triage accept

@k8s-ci-robot
Copy link
Contributor

@caesarxuchao: The label(s) triage/accept cannot be applied, because the repository doesn't have them.

In response to this:

/triage accept

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@caesarxuchao
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 4, 2021
@wojtek-t
Copy link
Member

wojtek-t commented May 5, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 5, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marseel, wojtek-t

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2021
@k8s-ci-robot k8s-ci-robot merged commit f94e8ba into kubernetes:master May 5, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone May 5, 2021
k8s-ci-robot added a commit that referenced this pull request Jun 8, 2021
…652-upstream-release-1.21

Automated cherry pick of #101652: Add jitter to lease controller
k8s-ci-robot added a commit that referenced this pull request Jun 8, 2021
…652-upstream-release-1.20

Automated cherry pick of #101652: Add jitter to lease controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants