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

Parallelize creating cluster snapshot #7630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

macsko
Copy link
Member

@macsko macsko commented Dec 19, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Creating cluster snapshots using SetClusterState can take a long time, especially in large clusters with plenty of pods. Fortunately, we can parallelize the work done per each node. This PR does it by calling workqueue.ParallelizeUntil capped at 16 workers.

I verified the performance and it gives me near 7 times faster execution for 1k nodes, 40k pods scenario, but it depends on the machine's CPU.

In the future, basic store used for scale down can be also changed similarly.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Adding pods when creating a cluster snapshot for scale up is now parallelized, improving performance. Parallelization can be adjusted or disabled by setting the cluster-snapshot-parallelization flag.

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


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. area/cluster-autoscaler labels Dec 19, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: macsko
Once this PR has been reviewed and has the lgtm label, please assign x13n for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 19, 2024
@macsko
Copy link
Member Author

macsko commented Dec 19, 2024

@yaroslava-serdiuk
Copy link
Contributor

Wow, cool feature!
Let's make in backwards compatible by introducing a flag. We can default it to 16, but in this case let's add release note since we change the behavior. In case this feature will brake someone (seems unlikely, but still we need to consider all scenarious) it should be easy to disable it (set flag to 1).

@yaroslava-serdiuk
Copy link
Contributor

cc: @x13n

@macsko macsko force-pushed the parallelize_cluster_snapshot_creation branch from 7368ae8 to f621876 Compare December 19, 2024 11:04
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 19, 2024
@macsko macsko force-pushed the parallelize_cluster_snapshot_creation branch from f621876 to 76eb858 Compare December 19, 2024 11:09
@macsko
Copy link
Member Author

macsko commented Dec 19, 2024

Let's make in backwards compatible by introducing a flag.

Added. If the flag is > 1, the snapshot is created using a new way.

@yaroslava-serdiuk
Copy link
Contributor

Overall LGTM
Thanks! Could you also mention how did you measure performance? I suppose it's a CA loop duration, right?

@x13n Could you take a look?

Copy link
Member

@x13n x13n left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Out of curiosity, did you test it only on the Go benchmarks or in an actual cluster? I wonder how much it improves in practice.

cluster-autoscaler/config/autoscaling_options.go Outdated Show resolved Hide resolved
cluster-autoscaler/main.go Outdated Show resolved Hide resolved
@macsko macsko force-pushed the parallelize_cluster_snapshot_creation branch from 76eb858 to 60477f7 Compare December 20, 2024 15:11
@macsko macsko force-pushed the parallelize_cluster_snapshot_creation branch from 60477f7 to b53877b Compare December 20, 2024 15:17
@macsko
Copy link
Member Author

macsko commented Dec 20, 2024

I wonder how much it improves in practice.

Yes, I tested it, but forgot to write. Before the change, in real cluster, for 1k nodes and 40k pods scale, a single SetClusterState took 300-500ms. With this improvement it takes 40-100ms.

@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants