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

Incorrect behavior on scaling up when using behaviors config on HPA #96671

Closed
DmitrySemchenok opened this issue Nov 18, 2020 · 4 comments · Fixed by #97348
Closed

Incorrect behavior on scaling up when using behaviors config on HPA #96671

DmitrySemchenok opened this issue Nov 18, 2020 · 4 comments · Fixed by #97348
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling.

Comments

@DmitrySemchenok
Copy link

When configuring new behaviors section in HPA I faced two scenarios that I think are incorrect.
First one:
stabilizationWindowSeconds set up to 5 minutes for both scale up and scale down
min replica count 2
Application consumes big amount of resources during warm-up
0 minute: current replica count: 2
1 minute: desired replica count: 3 - no scale up stabilization window worked
2 minute: desired replica count: 1 (!) - scale up to 3 (max number from previous recommendations during stabilization window period)
Algorithm

Second one
Stabilization window for scale up 0
Stabilization window for scale down 5 minutes
min replica count 2
behavior set to scale up new pod in 2 minutes
scaleUp:
policies:
- type: Pods
value: 1
periodSeconds: 120
What happens:
0 minute: 2 replicas
1 minute : performance spike scale up to 3 (desired value 4)
2 minute : no spike no scale up
3 minute: no spike scale up to 4(!) - supposedly desired value 1 and supposedly worked this way because of scale down window set to 5 minutes picking max value from that 5 minutes window that was 4 replicas

Expected behaviors
1 Scenario no scale up for 5 minutes
2 Scenario correct measurement and no scale up when there is no need for it

Environment:

  • Kubernetes version (use kubectl version): client 1.19.3 Server 1.19.0
  • Cloud provider or hardware configuration: Azure aks
@DmitrySemchenok DmitrySemchenok added the kind/bug Categorizes issue or PR as related to a bug. label Nov 18, 2020
@k8s-ci-robot k8s-ci-robot added 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. labels Nov 18, 2020
@k8s-ci-robot
Copy link
Contributor

@DmitrySemchenok: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@arjunrn
Copy link
Contributor

arjunrn commented Nov 18, 2020

/sig autoscaling

@k8s-ci-robot k8s-ci-robot added sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 18, 2020
@josephburnett
Copy link
Member

/assign josephburnett

@josephburnett
Copy link
Member

josephburnett commented Dec 16, 2020

The HPA controller keeps a flat history of recommendations for stabilization.
image

When downscale stabilizing the maximum recommendation is selected. Purple is pre-stabilized recommendation. Green is final recommendation. Blue is max recommendation within window.
image

When upscale stabilization the minimum recommendation is selected.
image

However when both up and down scale stabilization is configured, the interpretation of the history changes depending on the direction of movement. Red is the undesired, actuated recommendation.
image

What we want is to keep the stabilized recommendation within the envelope of the minimum and maximum over configured stabilization windows. We should only move when the envelope forces a move.
image

We first stabilize up and down, and check if the current value fits within it. If it does (or the range is "inverted"), we do nothing. If it does not, we emit the "nearest possible" value, which will be lower or upper bound, depending on where the current size is in relation to the range.

(thanks @konryd and @kgolab for the paragraph above)

konryd added a commit to konryd/website that referenced this issue Jan 7, 2021
The current explanation is misleading (for example: for consistently decreasing resource usage, the HPA stabilization does not impact the frequency of its actuation). This has confused users recently ( kubernetes/kubernetes#96671 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants