Skip to content

Auto Scaling

In one line

Auto scaling automatically adjusts the number of running instances (pods, servers) based on current load.

In simple words

Auto scaling is the ability of a system to automatically increase or decrease its capacity based on demand. When traffic is high, more instances are added. When traffic drops, instances are removed to save resources.

There are three types of auto scaling in Kubernetes: Horizontal — adds or removes Pods (scales out/in). This is the most common type. Vertical — increases or decreases CPU/memory per Pod (scales up/down). Cluster — adds or removes entire nodes (scales the cluster itself).

Auto scaling requires a metrics source (like Prometheus or the Kubernetes Metrics Server) to provide current CPU/memory usage or custom metrics. Based on these metrics, the scaler decides how many instances to run.

Example

yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: my-app-hpa
spec:
  scaleTargetRef:
    kind: Deployment
    name: my-app
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

This HPA scales the my-app Deployment between 2 and 10 Pods to keep CPU usage around 70%.

How it works

  1. A metrics source collects CPU/memory or custom metrics.
  2. The auto scaler checks metrics at regular intervals.
  3. If metrics exceed the target, it adds more instances.
  4. If metrics are below the target, it removes instances (down to minReplicas).

Common confusions

  • Confused with: Manual Scaling

    The difference: Manual scaling requires a human to change the replica count; auto scaling does it automatically based on metrics, responding to load changes in real time.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary