Skip to main content
RunBook Academy

KubernetesLXXXII · Horizontal Pod AutoscalerHorizontal Pod Autoscaler

Scaling policies — controlling the rate of change

Advanced⏱ ~12 minkubectlhey

What you'll learn

  • Configure the scaling policies
  • Distinguish Percent and Pods policies
  • Use selectPolicy for combined policies
  • Test the scaling rate

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

The HPA scaling policies control the rate of change. The Percent policy scales by a percentage of the current replicas; the Pods policy scales by a fixed number of pods. The selectPolicy combines multiple policies. This lesson walks the policies, the selectPolicy, and the production tuning.

The policies

The two policy types:

scaleUp:
  policies:
  - type: Percent
    value: 100
    periodSeconds: 30
  - type: Pods
    value: 4
    periodSeconds: 30
  selectPolicy: Max
  • Percent: scale up by N% of current replicas per period.
  • Pods: scale up by N pods per period.
flowchart LR
    A[Scaling policies] --> B[Percent]
    A --> C[Pods]
    B --> D[N% of current replicas per period]
    C --> E[N pods per period]

The Percent policy

The Percent policy scales by a percentage of the current replicas:

- type: Percent
  value: 100
  periodSeconds: 30

The example: 100% of current replicas per 30s. A workload with 5 replicas can scale to 10 replicas in 30s.

Current replicas: 5
100% per 30s: 5 + 5 = 10 replicas in 30s
200% per 30s: 5 + 10 = 15 replicas in 30s

The percent is of the current replicas, not the desired.

The Pods policy

The Pods policy scales by a fixed number of pods:

- type: Pods
  value: 4
  periodSeconds: 30

The example: 4 pods per 30s. A workload with 5 replicas can scale to 9 replicas in 30s.

Current replicas: 5
4 pods per 30s: 5 + 4 = 9 replicas in 30s

The Pods policy is independent of the current replicas; it is a fixed-rate scaling.

The selectPolicy

The selectPolicy combines multiple policies:

scaleUp:
  policies:
  - type: Percent
    value: 100
    periodSeconds: 30
  - type: Pods
    value: 4
    periodSeconds: 30
  selectPolicy: Max
  • Max: use the larger of the two policies.
  • Min: use the smaller of the two policies.
  • Disabled: disable scaling in this direction.

The Max policy is the production default for scale-up (use the more aggressive scaling). The Min policy is the production default for scale-down (use the more conservative scaling).

flowchart LR
    A[Two policies] --> B{selectPolicy?}
    B -->|Max| C[Use the larger value]
    B -->|Min| D[Use the smaller value]
    B -->|Disabled| E[Disable this direction]

The practical example

For a workload with 5 replicas:

Percent policy: 100% per 30s → 5 + 5 = 10
Pods policy: 4 pods per 30s → 5 + 4 = 9

selectPolicy: Max → 10 replicas in 30s

For a workload with 50 replicas:

Percent policy: 100% per 30s → 50 + 50 = 100
Pods policy: 4 pods per 30s → 50 + 4 = 54

selectPolicy: Max → 100 replicas in 30s

The Percent policy scales more aggressively for large workloads; the Pods policy scales more aggressively for small workloads.

The scale-down policies

The scale-down policies are the inverse:

scaleDown:
  policies:
  - type: Percent
    value: 10
    periodSeconds: 60
  - type: Pods
    value: 1
    periodSeconds: 60
  selectPolicy: Min

The example: 10% per 60s OR 1 pod per 60s, whichever is smaller.

For a workload with 50 replicas:

Percent policy: 10% per 60s → 50 - 5 = 45
Pods policy: 1 pod per 60s → 50 - 1 = 49

selectPolicy: Min → 45 replicas in 60s

The Min policy is the conservative choice.

The Disabled policy

The Disabled policy prevents scaling in a direction:

scaleDown:
  selectPolicy: Disabled

The HPA does not scale down. The replica count is fixed at the current value.

The Disabled policy is used when:

  • The workload is batch-processing; the pods are needed for a long time.
  • The workload is critical; the cluster’s other mechanisms (Cluster Autoscaler) handle the scale-down.
  • The workload’s pods are not safe to terminate (e.g., a long-running job).

The rate of change

The rate of change is bounded by the policies:

A workload with 5 replicas, scale-up:
  - Percent 100% per 30s: 5 → 10 → 20 → 40 (each 30s)
  - 4 pods per 30s: 5 → 9 → 13 → 17 (each 30s)
  - Max: 5 → 10 → 20 → 40 (each 30s)

A workload with 100 replicas, scale-down:
  - Percent 10% per 60s: 100 → 90 → 81 → 73 (each 60s)
  - 1 pod per 60s: 100 → 99 → 98 → 97 (each 60s)
  - Min: 100 → 90 → 81 → 73 (each 60s)

The rate is bounded by the policies.

The production tuning

The production tuning:

behavior:
  scaleUp:
    stabilizationWindowSeconds: 0
    policies:
    - type: Percent
      value: 100
      periodSeconds: 30
    - type: Pods
      value: 4
      periodSeconds: 30
    selectPolicy: Max
  scaleDown:
    stabilizationWindowSeconds: 300
    policies:
    - type: Percent
      value: 10
      periodSeconds: 60
    - type: Pods
      value: 1
      periodSeconds: 60
    selectPolicy: Min

The policy is per-workload. Critical workloads may have different rates than non-critical workloads.

Cross-course references

  • The Helm course covers chart values for HPA behavior.
  • The Observability course covers HPA metrics.
  • The KEDA course covers advanced scaling behaviors.

Quiz

Knowledge check · 4 questions

  1. Q1. What is the Percent policy?

  2. Q2. selectPolicy: Max is the production default for scale-down.

  3. Q3. Walk the configuration of the HPA scaling policies for a workload with 100 replicas.

    Deployment with 100 replicas. The workload is a web service that needs fast scale-up (spike handling) and slow scale-down (avoid premature cuts).

  4. Q4. When is selectPolicy: Disabled used?

Passing score: 75%. Answers are checked in this browser.

Production discipline

  • Configure the policies. Percent and Pods.
  • Use selectPolicy: Max for scale-up. Aggressive scaling.
  • Use selectPolicy: Min for scale-down. Conservative scaling.
  • Tune the periodSeconds. Per workload.
  • Use Disabled when appropriate. For fixed-replica workloads.
  • Test the rates. Generate load; verify the scaling.

The scaling policies are the HPA’s rate of change. Operating it well is configuring the policies and testing the rates.