<p>Kubernetes allows to limit pod resource usage.</p>

<pre><code>requests:
  cpu: 100m
  memory: 128Mi
limits:
  cpu: 200m   # which is 20% of 1 core
  memory: 256Mi
</code></pre>

<p>Let's say my kubernetes node has 2 core. And I run this pod with limit of CPU: 200m on this node. In this case, will my pod use it's underlying node's <strong>1Core's 200m</strong> or <strong>2Core's 100m+100m</strong>?</p>

<p>This calculation is needed for my <a href="http://docs.gunicorn.org/en/stable/design.html#how-many-workers" rel="noreferrer">gunicorn worker's number formula</a>, or nginx worker's number etc..
In gunicorn documentation it says </p>

<blockquote>
  <p>Generally we recommend (2 x $num_cores) + 1 as the number of workers
  to start off with.</p>
</blockquote>

<p>So should I use 5 workers? (my node has 2 cores). Or it doesn't even matter since my pod has only allocated 200m cpu and I should consider my pod has 1 core?</p>

<p><em><strong>TLDR:</strong></em> How many cores do pods use when its cpu usage is limited by kubernetes? If I run <code>top</code> inside pod, I'm seeing 2 cores available. But I'm not sure my application is using this 2 core's 10%+10% or 1core's 20%..</p>

<p>It will limit to 20% of one core, i.e. 200m. Also, <code>limit</code> means a pod can touch a maximum of that much CPU and no more. So pod CPU utilization will not always touch the limit.</p>

<p>Total CPU limit of a cluster is the total amount of cores used by all nodes present in cluster.</p>

<p>If you have a 2 node cluster and the first node has 2 cores and second node has 1 core, K8s CPU capacity will be 3 cores (2 core + 1 core). If you have a pod which requests 1.5 cores, then it will not be scheduled to the  second node, as that node has a capacity of only 1 core. It will instead be scheduled to first node, since it has 2 cores.</p>
