<p>I wish to run the Spring batch application in Azure Kubernetes.</p>
<p>At present, my on-premise VM has the below configuration</p>
<ul>
<li>CPU Speed: 2,593</li>
<li>CPU Cores: 4</li>
</ul>
<p>My application uses multithreading(~15 threads)</p>
<p>how do I define the CPU in AKS.</p>
<pre><code>resources:
  limits:
    cpu: &quot;4&quot;
  requests:
    cpu: &quot;0.5&quot;
args:
- -cpus
- &quot;4&quot;
</code></pre>
<p><strong>Reference:</strong> <a href="https://stackoverflow.com/questions/53276398/kubernetes-cpu-multithreading">Kubernetes CPU multithreading</a></p>
<p><strong>AKS Node Pool:</strong>
<a href="https://i.stack.imgur.com/HMpKg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HMpKg.png" alt="enter image description here" /></a></p>

<p>I'm afraid there is no easy answer to your question, while planning the right size of VM Node Pools for Kubernetes cluster to fit appropriately your workload requirements for resource consumption . This is a constant effort for cluster operators, and requires you to take into account many factors, let's mention few of them:</p>
<ol>
<li><p>What Quality of Service (QoS) class (Guaranteed, Burstable, BestEffort) should I specify for my Pod Application, and how many of them I plan to run ?</p>
</li>
<li><p>Do I really know the actual usage of CPU/Memory resources by my app VS. how much of VM compute resources stay idle ? (any on-prem monitoring solution in place right now, that could prove it, or be easily moved to Kubernetes in-cluster one ?)</p>
</li>
<li><p>Do my cluster is multi-tenant environment, where I need to share cluster resources with different teams ?</p>
</li>
<li><p>Node (VM) capacity is not the same as total available resources to workloads</p>
</li>
</ol>
<p>You should think here in terms of cluster Allocatable resources:</p>
<p><strong>Allocatable</strong> = Node Capacity - <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/" rel="nofollow noreferrer">kube-reserved</a> - <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/" rel="nofollow noreferrer">system-reserved</a></p>
<p>In case of <em>Standard_D16ds_v4</em> VM size in AZ, you would have for workloads disposal: 14 CPU Cores not 16 as assumed earlier.</p>
<h2></h2>
<p><strong>I hope you are aware</strong>, that scpecified through args number of CPUs:</p>
<pre><code>   args:
    - -cpus
    - &quot;2&quot;
</code></pre>
<p>is app specific approach (in this case the 'stress' utility written in go), not general way to spawn a declared number of threads per CPU.</p>
<h2></h2>
<p><strong>My suggestion:</strong></p>
<p>To avoid over-provisioning or under-provisioning of cluster resources to your workload application (requested resource VS. actually utilized resources), and to optimize costs and performance of your applications, I would in your place do a preliminary sizing estimation on your own of VM Node Pool size and type required by your SpringBoot multithreaded app, and thus familiarize first with concepts like <code>bin-packing</code> and <code>app right-sizing</code>. For these two last topics I don't know a better public guide than recently published by GCP tech team:</p>
<blockquote>
<p>&quot;<a href="https://cloud.google.com/architecture/monitoring-gke-clusters-for-cost-optimization-using-cloud-monitoring" rel="nofollow noreferrer">Monitoring gke-clusters for cost optimization using cloud monitoring</a>&quot;</p>
</blockquote>
<p>I would encourage you to find an answer to your question by your self. Do the proof of concept on GKE first (with <a href="https://cloud.google.com/free" rel="nofollow noreferrer">free  trial</a>), replace in quide above the demo app with your own workload, come back here, and share your own observation, would be valuable for others too with similar task !</p>
