<p>Getting started with Kubernetes so have the following question:</p>
<p>Say a microservice has the following C# code snippet:</p>
<pre><code>   var tasks = _componentBuilders.Select(b =&gt;
    {
       return Task.Factory.StartNew(() =&gt;  b.SetReference(context, typedModel));
    });

    Task.WaitAll(tasks.ToArray());
</code></pre>
<p>On my box, I understand that each thread be executed on a vCPU.  So if I have 4 cores with hyperthreading enabled I will be able to execute 8 tasks concurrently.  Therefore, if I have about 50000 tasks, it will take roughly</p>
<pre><code>(50,000/8) * approximate time per task 
</code></pre>
<p>to complete this work.  This ignores context switch, etc.</p>
<p>Now, moving to the cloud and assuming this code is in a docker container managed by Kubernetes Deployment and we have a single docker container per VM to keep this simple.  How does the above code scale horizontally across the VMs in the deployment?  Can not find very clear guidance on this so if anyone has any reference material, that would be helpful.</p>

Klaus Nji
<p>In Kubernetes, when we deploy containers as Pods we can include the <code>resources.limits.cpu</code> and <code>resources.requests.cpu</code> fields for each container in the Pod's manifest:</p>
<pre><code>resources:
  requests:
    cpu: &quot;1000m&quot;
  limits:
    cpu: &quot;2000m&quot;
</code></pre>
<p>In the example above we have a request for <code>1 CPU</code> and a limit for a maximum of <code>2 CPUs</code>. This means the Pod will be scheduled to a worker node which can satisfy above resource requirements.</p>
<p>One cpu, in Kubernetes, is equivalent to <code>1 vCPU/Core</code> for cloud providers and <code>1 hyperthread</code> on bare-metal Intel processors.</p>
<p>We can vertically scale by increasing / decreasing the values for the <code>requests</code> and <code>limits</code> fields. Or we can horizontally scale by increasing / decreasing the number of replicas of the pod.</p>
<p>For more details about resource units in Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes" rel="nofollow noreferrer">here</a></p>
