<p>I have a spring-boot application running over Kubernetes, Now I am trying to set up a horizontal pod auto scaler.</p>
<p>I have one doubt, without modifying any autoscalar thresholds, does auto scaler check pods only when they are ready(after the readiness probe succeeds) or even when readiness is not complete.</p>
<p>Example</p>
<ul>
<li>A Java app takes 5 mins to start(i.e to complete the readiness probe)</li>
<li>During this 5 mins, CPU for this app with 100% of the CPU requests assigned</li>
<li>HPA is configured to scale if targetCPUUtilization reaches 50%</li>
<li>Now what would happen in this case when the HPA condition is satisfied but the pod is not ready yet? Will it add one more pod right away or it will first wait for pods to be ready and then starts the timer for -<strong>horizontal-pod-autoscaler-initial-readiness-delay ?</strong></li>
</ul>
<p>I am assuming answer lies in this, but not clear to me</p>
<blockquote>
<p>Due to technical constraints, the HorizontalPodAutoscaler controller
cannot exactly determine the first time a pod becomes ready when
determining whether to set aside certain CPU metrics. Instead, it
considers a Pod &quot;not yet ready&quot; if it's unready and transitioned to
unready within a short, configurable window of time since it started.
This value is configured with the
--horizontal-pod-autoscaler-initial-readiness-delay flag, and its default is 30 seconds. Once a pod has become ready, it considers any
transition to ready to be the first if it occurred within a longer,
configurable time since it started. This value is configured with the
--horizontal-pod-autoscaler-cpu-initialization-period flag, and its default is 5 minutes</p>
</blockquote>
<p>Also, can anyone <strong>explain horizontal-pod-autoscaler-cpu-initialization-period</strong> &amp; <strong>horizontal-pod-autoscaler-initial-readiness-delay</strong> ? Documentation is confusing</p>

Ankit Bansal
<p>A <a href="https://github.com/jthomperoo/predictive-horizontal-pod-autoscaler" rel="nofollow noreferrer">Digital OCean Predictive Horizontal Pod Autoscaler</a> has the same kind of parameter: <a href="https://predictive-horizontal-pod-autoscaler.readthedocs.io/en/latest/reference/configuration/#cpuinitializationperiod" rel="nofollow noreferrer"><code>cpuInitializationPeriod</code></a>.</p>
<p>It rephrases what  <code>--horizontal-pod-autoscaler-cpu-initialization-period</code> as:</p>
<blockquote>
<p>the period after pod start when CPU samples might be skipped.</p>
</blockquote>
<p>And for <code>horizontal-pod-autoscaler-initial-readiness-delay</code></p>
<blockquote>
<p>the period after pod start during which readiness changes will be treated as initial readiness.</p>
</blockquote>
<p>The idea is to:</p>
<ul>
<li>not trigger any scaling based on CPU change alone (because the initial <code>cpu-initialization-period</code> means the pod is still being ready, with potential CPU spike)</li>
<li>not trigger any scaling based on readiness state changes (because the initial <code>readiness-delay</code> means, even if the pod reports it is ready, that can change during that delay)</li>
</ul>
<p><a href="https://github.com/kubernetes/website/issues/12657" rel="nofollow noreferrer"><code>kubernetes/website</code> issue 12657</a> has more (mainly to confirm the original documentation is confusing).</p>
