Runtime.getRuntime().availableProcessors() is always returning 1 on Container-Optimized OS

7/12/2019

I'm deploying elasticsearch on kubernetes engine on GCP and running into aperformance issue. Elasticsearch determines the size of various thread pools based on the number of cores. Even though I have an 32 core VM created, the thread pool size is just 1.

I did write a test program to print the Runtime.getRuntime().availableProcessors() and it just prints as 1.

I guess it has something to do with the "Container-Optimized OS" which is the only OS allowed on the VMs using Kubernetes Engine. When i create an Debian VM on GCP the Runtime.getRuntime().availableProcessors() returns 8. Not sure how is elasticsearch is being used on the GCPs kubernetes engine. Any ideas or suggestions are welcome.

When i create an Debian VM on GCP without kubernetes, the Runtime.getRuntime().availableProcessors() returns 8.

-- Shankar Shantharaju
elasticsearch
google-kubernetes-engine
java
kubernetes

0 Answers