> For the complete documentation index, see [llms.txt](https://docs.perfectscale.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectscale.io/visibility-and-optimization/combining-vertical-podfit-and-horizontal-hpa-optimization.md).

# Combining vertical (Podfit) and horizontal (HPA) optimization

Optimize VPA resource requests and HPA settings together to reduce waste without compromising workload scaling

VPA right-sizing and HPA scaling are closely connected because HPA triggers are calculated as a percentage of resource requests.

{% hint style="success" %}
The order of changes matters: right-size resource requests first, then review HPA settings based on the updated requests.
{% endhint %}

## **Why VPA and HPA are connected**

An HPA trigger determines how much of the requested CPU or memory must be used before HPA scales the workload. PerfectScale uses observed usage and the trigger value to calculate the recommended request.

For example:

* **50% trigger:** the recommended request is about 2× the observed usage.
* **80% trigger:** the recommended request is about 1.25× the observed usage.

The relationship works both ways. Resource requests and limits also affect the highest HPA trigger that can be reached before CPU throttling or a memory limit causes the container to be killed. After right-sizing, review the HPA triggers to make sure they still allow the workload to scale as expected.

{% hint style="warning" %}
**Do not tune the same signal in two places.** Let HPA manage horizontal scaling and PerfectScale manage resource requests. Avoid running another vertical scaling tool in automation mode on the same CPU or memory metrics used by HPA.
{% endhint %}

## **Recommended workflow**

{% stepper %}
{% step %}
**Start in the HPA view**

Filter by HPA to list the workloads that scale horizontally and see which ones have HPA recommendations.
{% endstep %}

{% step %}
**Apply vertical right-sizing first**

Apply the CPU and memory request recommendations, manually or with automation. Requests that match real usage give the HPA a correct baseline.

{% hint style="info" %}
**Use the Optimization Policy to set headroom.** If a workload needs more resilience, set a higher policy such as ExtraHeadroom rather than a very low trigger.
{% endhint %}
{% endstep %}

{% step %}
**Review HPA recommendations**

A new request changes the highest usable trigger, so a trigger that worked before can be no longer relevant. Check the recommendations after the new revision have been running.
{% endstep %}

{% step %}
**Fix `minReplicas`**

Lower values left over from past incidents. This is the largest source of idle capacity on HPA workloads, and it does not depend on request sizing.

{% hint style="info" %}
**Treat `at max replicas` as a scaling signal, not a sizing problem.** If a workload stays at `maxReplicas`, vertical right-sizing will not fix it. Review `maxReplicas` and scale-down behavior yourself, since PerfectScale does not recommend changes to them.
{% endhint %}
{% endstep %}

{% step %}
**Raise low triggers**

Lower triggers inflate requests and cost.

{% hint style="info" %}
**Use container-level triggers for multi-container pods.** A sidecar can hide the application's load in a pod-level average. Container triggers require a supported Kubernetes version, so check your cluster version first (we recommend Kubernetes version **1.33 or later**)
{% endhint %}
{% endstep %}

{% step %}
**Lower unreachable triggers**

Align them with the highest usable trigger, or adjust the limit if the trigger value is intentional. HPA needs enough headroom above the utilization target to trigger scaling. Resource limits can restrict this headroom, making higher targets unreachable or increasing the risk of OOM kills.
{% endstep %}

{% step %}
**Re-check after the Revisions Timeline shows the change**

Confirm in the Replicas widget that scaling behaves as expected.
{% endstep %}
{% endstepper %}
