Skip to main content

Vertical Pod Autoscaler (VPA)

Key Takeaways for AI & Readers
  • Vertical Scaling: Vertical Pod Autoscaler (VPA) automatically adjusts the CPU and memory requests of individual Pods, optimizing resource allocation.
  • Complementary to HPA: VPA scales vertically (single Pod), while HPA scales horizontally (multiple Pods), making them suitable for different application types.
  • Operational Modes: VPA offers various modes, including "Recommendation Only," "Initial" (only on Pod creation), and "Auto/Recreate" (restarts Pods for adjustments), each with different impacts on stability.
  • Cost and Stability Benefits: VPA helps reduce cloud costs by eliminating over-provisioning and improves application stability by preventing out-of-memory errors.

While HPA adds more Pods (Horizontal scaling), VPA makes existing Pods larger or smaller by adjusting their CPU and Memory Requests.

1. HPA vs. VPA

  • HPA: Good for stateless apps that can scale wide.
  • VPA: Good for stateful apps or apps that aren't built for horizontal scaling (e.g., single-threaded Java apps).

Application Load

VPA Recommendation
Target CPU: 100m
Pod Size (Vertical)
📦
RESOURCES
Unlike HPA which adds more pods, Vertical Pod Autoscaler (VPA) updates the Requests and Limits of a single pod to match its actual usage.

2. VPA Modes

Off (Recommendation Only)

VPA only calculates the recommended resources and shows them in the status. It does NOT change the pod. This is the safest way to start.

Initial

VPA only sets the resources when the Pod is first created. It won't restart a running pod.

Auto / Recreate

VPA will kill a running pod and recreate it with the new CPU/Memory settings.

  • Warning: Since Pods must be restarted to change their resources, you must have enough replicas to handle the downtime.

3. Why use VPA?

  1. Reduce Costs: Stop paying for "Ghost" resources that were requested but never used.
  2. Increase Stability: Prevent OOMKills (Out of Memory) by automatically giving more RAM to pods that are nearing their limits.