I'm running a Java app inside of a docker container, which is restricted to 4 CPU and the machine on which the docker container runs, has 10 CPU.
When calling nproc inside the docker container, I get as a result 4, but when I call Runtime.getRuntime().availableProcessors() I get 10 as result.
Java see all CPU?Java the same result asa nproc, besides using Runtime.getRuntime().exec("nproc")?According to Ken Sipe (link below) there is a bug in java for showing the wrong no of cpus/cores when using shared cpus (default in docker) instead of cpusets (pinned cpus for a process).
I myself however see the wrong number regardless this setting:
Runtime.availableProcessors(), no docker: 8 in docker I always get 4,
whereas nproc says 1 (when using --cpuset-cpus=0 <- pinned on cpu0)
see https://vimeo.com/138955223
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With