stabilizationWindowSeconds 稳定窗口期

节选自: https://github.com/kubernetes/enhancements/blob/master/keps/sig-autoscaling/853-configurable-hpa-scale-velocity/README.md#algorithm-pseudocode
避免翻译错误导致误导直接粘贴原版

1. Stabilization before scaling down

This mode is used when the user expects a lot of flapping or does not want to scale down pods too early expecting some late load spikes.

Create an HPA with the following behavior:

behavior:
  scaleDown:
    stabilizationWindowSeconds: 600
    policies:
    - type: Pods
      value: 5
      periodSeconds: 600

i.e., the algorithm will:

  • gather recommendations for 600 seconds (default: 300 seconds)
  • pick the largest one
  • scale down no more than 5 pods per minute
    Example for CurReplicas = 10 and HPA controller cycle once per a minute:

First 9 minutes the algorithm will do nothing except gathering recommendations. Let's imagine that we have the following recommendations

recommendations = [10, 9, 8, 9, 9, 8, 9, 8, 9]

On the 10th minute, we'll add one more recommendation (let it me 8):

recommendations = [10, 9, 8, 9, 9, 8, 9, 8, 9, 8]

Now the algorithm picks the largest one 10. Hence it will not change number of replicas

On the 11th minute, we'll add one more recommendation (let it be 7) and removes the first one to keep the same amount of recommendations:

recommendations = [9, 8, 9, 9, 8, 9, 8, 9, 8, 7]

The algorithm picks the largest value 9 and changes the number of replicas 10 -> 9

2. Avoid false positive signals for scaling up

This mode is useful in Data Processing pipelines when the number of replicas depends on the number of events in the queue. The users want to scale up quickly if they have a high number of events in the queue. However, they do not want to react to false positive signals, i.e. to short spikes of events.

Create an HPA with the following behavior:

behavior:
  scaleUp:
    stabilizationWindowSeconds: 300
    policies:
    - type: Pods
      value: 20
      periodSeconds: 60

i.e., the algorithm will:

  • gather recommendations for 300 seconds (default: 0 seconds)
  • pick the smallest one
  • scale up no more than 20 pods per minute

Example for CurReplicas = 2 and HPA controller cycle once per a minute:

First 5 minutes the algorithm will do nothing except gathering recommendations. Let's imagine that we have the following recommendations

recommendations = [2, 3, 19, 10, 3]

On the 6th minute, we'll add one more recommendation (let it me 4):

recommendations = [2, 3, 19, 10, 3, 4]

Now the algorithm picks the smallest one 2. Hence it will not change number of replicas

On the 7th minute, we'll add one more recommendation (let it be 7) and removes the first one to keep the same amount of recommendations:

recommendations = [7, 3, 19, 10, 3, 4]

The algorithm picks the smallest value 3 and changes the number of replicas 2 -> 3

posted @ 2023-06-01 14:02  Dus  阅读(95)  评论(0编辑  收藏  举报