# Improper detection of available CPUs

**URL:** <https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282>\
**Category:** Elasticsearch\
**Created:** [August 7, 2019, 4:01pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282 "2019-08-07T16:01:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethrbunny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ethrbunny/32/34603_2.png) [@ethrbunny](https://discuss.elastic.co/u/ethrbunny)\
**Post date:** [August 7, 2019, 4:01pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/1 "2019-08-07T16:01:25Z")

</div>

Im running a 5 node cluster in kubernetes. Each k8 host has 56 cores but when I query for node information I get these values:

```
    "available_processors" : 1,
    "allocated_processors" : 1

```

Im using Java 12 so according to [this](https://www.oracle.com/technetwork/java/javase/10-relnote-issues-4108729.html#JDK-8146115) the correct value is supposed to be passed to the container(s).

Furthermore - if I open a shell to a running container and run `nproc` I get the correct value (56).

Have I misconfigured something? Do I need to manually specify # of cores to the JVM?

* * *

- Similar issue to [this](https://discuss.elastic.co/t/cores-usage-by-elasticsearch-on-kubernetes/180536) posting

---

<div class="post-metadata">

**Author:** ![RdrgPorto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rdrgporto/32/13278_2.png) [@RdrgPorto](https://discuss.elastic.co/u/RdrgPorto)\
**Post date:** [August 7, 2019, 6:42pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/2 "2019-08-07T18:42:36Z")

</div>

Hi @ethrbunny

It is necessary to set a limit in your **Kubernetes manifest**. For example, if my host had 4 cores, it would be:

```
containers:
- name: elasticsearch
  image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
  resources:
    requests:
      cpu: 500m 
    limits:
      memory: 4

```

Regards 🖖

Rodrigo

---

<div class="post-metadata">

**Author:** ![ethrbunny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ethrbunny/32/34603_2.png) [@ethrbunny](https://discuss.elastic.co/u/ethrbunny)\
**Post date:** [August 7, 2019, 9:45pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/3 "2019-08-07T21:45:06Z")

</div>

So don't change the JVM arguments?

NM - I think I get it now. Will have a go at it.

TY

---

<div class="post-metadata">

**Author:** ![RdrgPorto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rdrgporto/32/13278_2.png) [@RdrgPorto](https://discuss.elastic.co/u/RdrgPorto)\
**Post date:** [August 8, 2019, 3:12pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/4 "2019-08-08T15:12:51Z")

</div>

Hi, @ethrbunny

I have not changed any **JVM arguments**. I have set **a limit cpu** and it worked 🙂. There are some blogs on Internet that talk about this kind of issue. It depends on **Java version** and the proper application.

Regards 🖖

---

<div class="post-metadata">

**Author:** ![ethrbunny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ethrbunny/32/34603_2.png) [@ethrbunny](https://discuss.elastic.co/u/ethrbunny)\
**Post date:** [August 21, 2019, 5:03pm UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/5 "2019-08-21T17:03:26Z")

</div>

(sorry to keep bringing this up - ran into some confusing info)

Ran into this [doc](https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/#if-you-do-not-specify-a-cpu-limit) entry:

```
If you do not specify a CPU limit for a Container, then one of these situations applies:

* The Container has no upper bound on the CPU resources it can use. The Container could use all of the CPU resources available on the Node where it is running.

```

I checked the container definition(s) for my data nodes and there isn't a CPU request or limit set.

Does the cpu request / limit have to be set _no matter what_?

---

<div class="post-metadata">

**Author:** ![RdrgPorto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rdrgporto/32/13278_2.png) [@RdrgPorto](https://discuss.elastic.co/u/RdrgPorto)\
**Post date:** [August 22, 2019, 8:00am UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/6 "2019-08-22T08:00:53Z")

</div>

Hi, @ethrbunny

If you don't set a resource & limit on Kubernetes, that pod will use all resources of the machine.

However, in this case, Elasticsearch is a Java application. So that, it needs a CPU limit in order to take it account.

⚠ Not set a memory limit, Elasticsearch use file cache.

Regards 🖖,

Rodrigo

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 19, 2019, 8:09am UTC](https://discuss.elastic.co/t/improper-detection-of-available-cpus/194282/7 "2019-09-19T08:09:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
