<p>I am new to K8s autoscaling. I have a stateful application I am trying to find out which autoscaling method works for me. According to the documentation:</p>
<blockquote>
<p>if pods don't have the correct resources set, the Updater component
of VPA kills them so that they can be recreated by their controllers
with the updated requests.</p>
</blockquote>
<p>I want to know the downtime for kills the existing pod and creating the new ones. Or at least how can I measure it for my application?</p>
<p>I am comparing the HPA and VPA approaches for my application.</p>
<p>the follow-up question is - how long does it take in HPA to create a new pod in scaling up?</p>

SamiraM
<p>There are few things to clear out here:</p>
<ul>
<li><p>VPA does not create nodes, <a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler#cluster-autoscaler" rel="nofollow noreferrer">Cluster Autoscaler</a> is used for that. Vertical Pod Autoscaler allocates more (or less) CPUs and memory to existing pods and CA scales your node clusters based on the number of pending pods.</p>
</li>
<li><p>Whether to use HPA, VPA, CA, or some combination, depends on the needs of your application. Experimentation is the most reliable way to find which option works best for you, so it might take a few tries to find the right setup. HPA and VPA depend on metrics and some historic data. CA is recommended if you have a good understanding of your pods and containers needs.</p>
</li>
<li><p>HPA and VPA should not be used together to evaluate CPU/Memory. However, VPA can be used to evaluate CPU or Memory whereas HPA can be used to evaluate external metrics (like the number of HTTP requests or the number of active users, etc). Also, you can use VPA together with CA.</p>
</li>
<li><p>It's hard to evaluate the exact time needed for VPA to adjust and restart pods as well as for HPA to scale up. The difference between best case scenario and worse case one relies on many factors and can make a significant gap in time. You need to rely on metrics and observations in order to evaluate that.</p>
</li>
<li><p><a href="https://github.com/kubernetes-sigs/metrics-server#kubernetes-metrics-server" rel="nofollow noreferrer">Kubernetes Metrics Server</a> collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API for use by Horizontal Pod Autoscaler and Vertical Pod Autoscaler.</p>
</li>
</ul>
<p>Below are some useful sources that would help you understand and choose the right solution for you:</p>
<ul>
<li><p><a href="https://medium.com/nerd-for-tech/autoscaling-in-kubernetes-hpa-vpa-ab61a2177950" rel="nofollow noreferrer">AutoScaling in Kubernetes ( HPA / VPA )</a></p>
</li>
<li><p><a href="https://www.replex.io/blog/kubernetes-in-production-best-practices-for-cluster-autoscaler-hpa-and-vpa" rel="nofollow noreferrer">Kubernetes Autoscaling in Production: Best Practices for Cluster Autoscaler, HPA and VPA</a></p>
</li>
<li><p><a href="https://platform9.com/blog/kubernetes-autoscaling-options-horizontal-pod-autoscaler-vertical-pod-autoscaler-and-cluster-autoscaler/" rel="nofollow noreferrer">Kubernetes Autoscaling Options: Horizontal Pod Autoscaler, Vertical Pod Autoscaler and Cluster Autoscaler</a></p>
</li>
</ul>
<p><strong>EDIT:</strong></p>
<p>Scaling up is a time sensitive operation. You should consider the average time it can take your pods to scale up. Two example scenarios:</p>
<ol>
<li>Best case scenario  - 4 minutes:</li>
</ol>
<ul>
<li>30 seconds : Target metrics values updated: 30-60 seconds</li>
<li>30 seconds : HPA checks on metrics values: 30 seconds</li>
<li>&lt; 2 seconds:  pods created and goes into pending state  - 1 second</li>
<li>&lt; 2 seconds : CA sees the pending pods and fires up the calls to provision nodes  - 1 second</li>
<li>3 minutes:  Cloud provider provision the nodes &amp; K8 waits for them till they are ready: up to 10 minutes (depends on multiple factors)</li>
</ul>
<ol start="2">
<li>(Reasonable) Worst case scenario  - 12 minutes:</li>
</ol>
<ul>
<li>60 seconds : Target metrics values updated</li>
<li>30 seconds : HPA checks on metrics values</li>
<li>&lt; 2 seconds : pods created and goes into pending state</li>
<li>&lt; 2 seconds : CA sees the pending pods and fires up the calls to provision nodes</li>
<li>10 minutes : Cloud provider provision the nodes &amp; K8 waits for them till they are ready minutes (depends on multiple factors, such provider latency, OS latency, boot strapping tools, etc.)</li>
</ul>
<p>Again, it is hard to estimate the exact time it would take so observation and metrics are the key here.</p>
