<p>So before I used kubernetes the general rule I used for running multiple express instances on a VM was one per cpu. That seemed to give the best performance.
For kubernetes, would it be wise to have a replica per node cpu? Or should I let the horizontalpodautoscaler decide? The cluster has a node autoscaler.
Thanks for any advice!</p>

danthegoodman
<p>good question !</p>
<p>You need to consider 4 things :</p>
<ol>
<li><p>Run the pod using <strong>Deployment</strong> so you enable replication, rolling update,...so on</p>
</li>
<li><p>Set <code>resources.limits</code> to your container definition. this is mandatory for autoscaling , because HPA is monitoring the percentage of usage, and if there is <strong>NO limit</strong>, there will be <strong>NEVER percentage</strong>, then HPA will never reach the <strong>threshold</strong>.</p>
</li>
<li><p>Set <code>resources.requests</code>. This will help the scheduler to estimate how much the app needs, so it will be assigned to the suitable Node per its current capacity.</p>
</li>
<li><p>Set HPA threshold: The  percentage of usage (CPU, memory)  when the HPA will trigger scale out or scale in.</p>
</li>
</ol>
<p>for your situation, you said &quot;one per cpu&quot;.. then, it should be:</p>
<pre><code>  containers:
  - name: express
    image: myapp-node
    #.....
    resources:
      requests:
        memory: &quot;256Mi&quot;
        cpu: &quot;750m&quot;
      limits:
        memory: &quot;512Mi&quot;
        cpu: &quot;1000m&quot; # &lt;-- 🔴 match what you have in the legacy deployment
</code></pre>
<p>you may wonder why I put memory limits/requests without any input from your side ?
The answer is that I put it randomly. Your task is to monitor your application, and adjust all these values accordingly.</p>
