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

Upstream core Kubernetes HPA loop is single-threaded #2382

Closed
bpinske opened this issue Dec 4, 2021 · 4 comments
Closed

Upstream core Kubernetes HPA loop is single-threaded #2382

bpinske opened this issue Dec 4, 2021 · 4 comments
Labels
bug Something isn't working stale-bot-ignore All issues that should not be automatically closed by our stale bot upstream-integration All issues related to upstream Kubernetes/community

Comments

@bpinske
Copy link
Contributor

bpinske commented Dec 4, 2021

Report

I am leveraging Keda to query Prometheus for metrics to use in scaling decisions. Core Kubernetes appears to have some poor performance when it comes to operation with many external metrics based queries. The core HPA loop is single-threaded and acts on a single HPA object at a time in a blocking fashion on every loop iteration.

This core HPA loop should be concurrent and process every HPA object of the cluster at once as there is no mutability of the HPA objects themselves caused by other HPA objects.

This has an associated upstream issue opened describing the issuehere

The single threaded nature can be found here

Expected Behavior

Kubernetes' core HPA loop to be performant

Actual Behavior

It's possible for scaling decisions to be greatly delayed due to the sequential blocking nature of the core HPA loop. HPA simply cannot process all HPA objects sequentially in a timely manner.

Steps to Reproduce the Problem

  1. Create and install the https://github.com/kubernetes-sigs/custom-metrics-apiserver and alter its code to add a delay in the GetExternalMetric method of the Testing Provider

  2. Also add logging to the method with timestamps logrus supports timestamps, e.g.

  3. Create 1,000 HPA objects referring to that test metric - possibly 1,000 deployments as well, but one will work fine too even if not a real use case.

  4. Pick one of your HPA's and watch for the time between its call to GetExternalMetric.

Logs from KEDA operator

.

KEDA Version

2.5.0

Kubernetes Version

1.20

Platform

Any

Scaler Details

All of them!

Anything else?

No response

@bpinske bpinske added the bug Something isn't working label Dec 4, 2021
@zroubalik
Copy link
Member

Thanks for documenting this, we should try to work with SIG Autoscaling to tackle this.

@tomkerkhove tomkerkhove added the upstream-integration All issues related to upstream Kubernetes/community label Dec 7, 2021
@stale
Copy link

stale bot commented Feb 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Feb 5, 2022
@tomkerkhove tomkerkhove moved this to Backlog in Roadmap - KEDA Core Feb 10, 2022
@stale
Copy link

stale bot commented Feb 12, 2022

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Feb 12, 2022
Repository owner moved this from To Do to Ready To Ship in Roadmap - KEDA Core Feb 12, 2022
@zroubalik zroubalik added the stale-bot-ignore All issues that should not be automatically closed by our stale bot label Feb 12, 2022
@zroubalik zroubalik reopened this Feb 12, 2022
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Feb 12, 2022
Repository owner moved this from Ready To Ship to Proposed in Roadmap - KEDA Core Feb 12, 2022
@zroubalik
Copy link
Member

This has been fixed upstream.

@github-project-automation github-project-automation bot moved this from Proposed to Ready To Ship in Roadmap - KEDA Core Oct 21, 2023
@zroubalik zroubalik moved this from Ready To Ship to Done in Roadmap - KEDA Core Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale-bot-ignore All issues that should not be automatically closed by our stale bot upstream-integration All issues related to upstream Kubernetes/community
Projects
Archived in project
Development

No branches or pull requests

3 participants