title: JVM Runtime.getRuntime().availableProcessors() returns 1 on AWS ECS Fargate
body: <pre><code>public class Example {
     public static void main(String[] args) {
        // print statement at the start of the program
        System.out.println(&quot;Start...&quot;);
        System.out.print(&quot;Number of available processors are: &quot;);
        System.out.println( Runtime.getRuntime().availableProcessors());
     }
  }
  </code></pre>
  <p>Ref: <a href="https://www.tutorialspoint.com/get-number-of-available-processors-in-java" rel="nofollow noreferrer">https://www.tutorialspoint.com/get-number-of-available-processors-in-java</a></p>
  <p>When I compile and run this code on AWS ECS Fargate getting &quot;1&quot; as the output even though I have specified more than 1 cpu in task def(4098 for 4 vCPU).</p>
  <p><strong>Tested Java versions:</strong></p>
  <ul>
  <li>Corretto-17.0.0.35.1</li>
  <li>Corretto-8.275.01.1</li>
  </ul>
  <p>But when I do the same on AWS EC2 inside docker by allocating CPU with --cpus for &quot;docker run&quot; I get the exact number what I pass to --cpus. Same results with AWS EC2 with Containerd as well.</p>
  <p>Also tested this in EKS 1.18 by setting CPU limit. It returns the number of CPUs specified in the CPU limit.</p>
  <p>So, wondering why &quot;1&quot; only in AWS ECS.</p>