<p>We have configured to use 2 metrics for HPA</p>

<ol>
<li>CPU Utilization</li>
<li>App specific custom metrics</li>
</ol>

<p>When testing, we observed the scaling happening, but calculation of no.of replicas is not very clear. I am not able to locate any documentation on this.</p>

<p><strong>Questions:</strong></p>

<ol>
<li>Can someone point to documentation or code on the calculation part?</li>
<li>Is it a good practice to use multiple metrics for scaling?</li>
</ol>

<p>Thanks in Advance!</p>

<p>From <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#how-does-the-horizontal-pod-autoscaler-work" rel="noreferrer">https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#how-does-the-horizontal-pod-autoscaler-work</a></p>

<blockquote>
  <p>If multiple metrics are specified in a HorizontalPodAutoscaler, this calculation is done for each metric, and then the largest of the desired replica counts is chosen. If any of those metrics cannot be converted into a desired replica count (e.g. due to an error fetching the metrics from the metrics APIs), scaling is skipped.</p>
  
  <p>Finally, just before HPA scales the target, the scale recommendation is recorded. The controller considers all recommendations within a configurable window choosing the highest recommendation from within that window. This value can be configured using the <code>--horizontal-pod-autoscaler-downscale-stabilization-window</code> flag, which defaults to 5 minutes. This means that scaledowns will occur gradually, smoothing out the impact of rapidly fluctuating metric values</p>
</blockquote>
