articles / scalabilite-kubernetes-hpa-vpa

Horizontal and vertical scaling on Kubernetes: HPA, VPA and nodes

Mounir Guizani · 30 November 2026 · 5 min read

  • kubernetes
  • scalabilite
  • devops
  • java

On AWS, scaling often relies on managed services that do the work on their own. On Kubernetes, it's up to you to wire the mechanisms, at three levels: the pods, their resources, and the cluster's nodes. I set up a complete pre-production environment on Kubernetes at Société Générale; here is the pragmatic approach I took away from it.

The three levels of scaling

Level Horizontal Vertical
Pods HPA: more replicas of a Deployment VPA: more CPU and memory per pod
Nodes Cluster Autoscaler or Karpenter: more machines bigger machines (instance type)
Events KEDA: replicas based on a queue, a topic, a cron —

The levels chain together: the HPA creates pods; if they can't find room, they stay Pending; the node autoscaler then adds a machine.

It all starts with requests

Kubernetes places and scales pods based on their requests (what the pod reserves) and their limits (what it can't exceed):

resources:
  requests:
    cpu: "500m"
    memory: "768Mi"
  limits:
    memory: "768Mi"
  • The HPA computes CPU percentage relative to requests: made-up requests give made-up scaling.
  • For a JVM, the container memory must cover the heap and everything else (metaspace, threads). -XX:MaxRAMPercentage=75 lets the JVM adapt to the container size.
  • A CPU limit set too low causes throttling: the application slows down with no visible error. Many teams set a memory limit but no CPU limit.

Horizontal: the HPA

The Horizontal Pod Autoscaler adjusts the number of replicas to hold a target:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 60

What it takes to work well:

  • a stateless application (sessions and files outside the pod);
  • a reliable readiness probe: a pod only gets traffic once Spring is really ready;
  • a minimum of 2 replicas and a PodDisruptionBudget to survive maintenance;
  • the right metric: for a service waiting on network calls or consuming a queue, CPU lies. KEDA lets you scale on queue length (SQS, RabbitMQ, Kafka), even down to zero.

Vertical: the VPA

The Vertical Pod Autoscaler watches actual usage and recommends (or applies) better requests. How I use it:

  • in recommendation mode (updateMode: "Off") to size requests correctly from real measurements;
  • never with an HPA on the same metric (CPU or memory): the two mechanisms contradict each other;
  • carefully in automatic mode, which may recreate pods to apply the new values.

Vertical scaling is ideal for workloads that are hard to parallelise, or simply to stop guessing sizes.

Nodes: Cluster Autoscaler or Karpenter

When pods stay pending for lack of room, you need machines:

  • Cluster Autoscaler adds or removes nodes within predefined groups;
  • Karpenter (widely used on EKS) picks the instance type that fits the pending pods directly, and consolidates under-used nodes.

A node takes tens of seconds, even minutes, to start: keep some headroom, or anticipate known peaks.

What about batch jobs?

For a high-volume Spring Batch job, horizontal scaling goes through a Kubernetes Job:

  • parallelism sets how many pods work at the same time;
  • an indexed Job (completionMode: Indexed) gives each pod a number, ideal for processing one data partition per pod;
  • the real ceiling is often the database: ten pods in parallel also means ten times more writes.

Kubernetes or AWS managed services?

Kubernetes (EKS) ECS / Fargate / Lambda
Scaling mechanisms HPA, VPA, KEDA, Karpenter: powerful, to configure built in, few settings
Control granularity maximum enough in most cases
Operational effort significant low
Portability multi-cloud and on-premises tied to AWS

Kubernetes gives the finest control, at the cost of real operational expertise. If the platform already exists in the company, it's an excellent choice. Otherwise, managed services often deliver the same elasticity with far fewer moving parts.

My checklist

  1. Measured requests (the VPA in recommendation mode helps), not guessed ones.
  2. Stateless applications, with a readiness probe and graceful shutdown.
  3. An HPA on the right metric, or KEDA for queues and events.
  4. A node autoscaler and headroom to absorb peaks.
  5. A load test before production, with the database in scope.
Learned on a missionSociété Générale : Senior full stack developer & Scrum MasterSee the mission →