Cloud Technology

How to choose between HPA and VPA for Kubernetes scaling?

BR Asked by Brandon Miller · 14-05-2025
0 upvotes 15,492 views 0 comments
The question

I am managing a cluster where some microservices have unpredictable traffic spikes while others are just memory-hungry during data processing. I’m confused about whether I should implement the Horizontal Pod Autoscaler (HPA) or the Vertical Pod Autoscaler (VPA). Can they be used together on the same set of pods, or will they conflict with each other and cause cluster instability?

3 answers

0
KI
Answered on 17-05-2025

The general rule in Kubernetes is that you should not use HPA and VPA together on the same resource metrics (like CPU or Memory). If HPA is trying to add more pods based on CPU and VPA is trying to increase the CPU of the existing pods, they will fight each other, leading to "flapping" and resource waste. HPA is best for stateless apps that scale out easily with traffic. VPA is great for stateful jobs or "thick" applications where you can't easily distribute the load. If you must use both, set HPA to track a custom metric (like request count) while VPA manages the resource limits.

0
GR
Answered on 20-05-2025

If we use VPA, how do we handle the fact that it has to restart the pods to update the resource limits?

ST 23-05-2025

That is the main drawback of VPA, Gregory. Unlike HPA, which is non-disruptive, VPA's "Auto" mode kills the pod to recreate it with the new specs. To avoid downtime, you need to ensure your PodDisruptionBudgets are correctly configured. Alternatively, look into the "In-place Pod Vertical Scaling" feature introduced in recent K8s versions, which allows updating resources without a restart, though it’s still somewhat experimental and requires specific container runtime support to work reliably.

0
AS
Answered on 25-05-2025

For most web applications, HPA is the safer bet. It's much more mature and handles sudden traffic surges much better than VPA does.

BR 28-05-2025

Agreed, Ashley. I’ve found that VPA is a bit too slow for real-time spikes, whereas HPA spinning up 10 new pods is almost instantaneous.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

World globe icon Country: Canada

Book Free Session