# CPU affinity when running multiple nodes on a single host

**URL:** <https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611>\
**Category:** Elasticsearch\
**Created:** [May 7, 2020, 7:04pm UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611 "2020-05-07T19:04:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lechuck](https://avatars.discourse-cdn.com/v4/letter/l/8edcca/32.png) [@lechuck](https://discuss.elastic.co/u/lechuck)\
**Post date:** [May 7, 2020, 7:04pm UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/1 "2020-05-07T19:04:50Z")

</div>

Hi folks,

If running multiple Elasticsearch instances on a well resourced server (256GB RAM, 48 cores) , assuming the 'processors' count in elasticsearch.yml is set to a sensible value (max cores / number ES instances ) , is there a benefit to going further and also pinning the ES processes to specific CPUS (using CPUAffinity option in systemd unit file for example), or is it better to let the OS manage the thread scheduling?

Eg on a host running 3 instances, the processors count would be set to 16 for each host in the Elasticsearch config, ensuring each process only has access to a subset of CPU cores, but technically they can still share cores vs CPU pinning, where instance one is pinned to cores 0-7 , instance 2 pinned to cores 8-15 etc...

Any advice in this area would be appreciated, cheers.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [May 7, 2020, 8:37pm UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/2 "2020-05-07T20:37:09Z")

</div>

I've not heard of any benchmarks in this area, and even if I had I suspect the answer would still depend on your specific setup and workload. Probably best to [test this yourself](https://esrally.readthedocs.io/en/stable/).

---

<div class="post-metadata">

**Author:** ![lechuck](https://avatars.discourse-cdn.com/v4/letter/l/8edcca/32.png) [@lechuck](https://discuss.elastic.co/u/lechuck)\
**Post date:** [May 8, 2020, 5:08am UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/3 "2020-05-08T05:08:34Z")

</div>

No problem, thanks for the response. The official docs alluded to CPU pinning (see quote from the thread pool module doc below), but I haven't seen any further reference to specific implementation details, so I was wondering if I was missing any best practices in this area by not explicitly pinning instances to specific cores.

> 1. If you are running multiple instances of Elasticsearch on the same host but want want Elasticsearch to size its thread pools as if it only has a fraction of the CPU, you should override the `node.processors` setting to the desired fraction, for example, if you’re running two instances of Elasticsearch on a 16-core machine, set `node.processors` to 8. Note that this is an expert-level use case and there’s a lot more involved than just setting the `node.processors` setting as there are other considerations like changing the number of garbage collector threads, pinning processes to cores, and so on.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [May 8, 2020, 7:46am UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/4 "2020-05-08T07:46:52Z")

</div>

Indeed, it's plausible that CPU pinning might have a performance benefit, but it's also plausible that the OS is clever enough to do that for you anyway, and there's a risk that overconstraining the thread scheduler leads to worse performance. "Expert-level" means it's too complicated to give much general guidance in this area and you're expected to investigate this yourself.

---

<div class="post-metadata">

**Author:** ![lechuck](https://avatars.discourse-cdn.com/v4/letter/l/8edcca/32.png) [@lechuck](https://discuss.elastic.co/u/lechuck)\
**Post date:** [May 8, 2020, 9:25am UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/5 "2020-05-08T09:25:40Z")

</div>

Understood, some investigation required! Thanks

---

<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:** [June 5, 2020, 9:33am UTC](https://discuss.elastic.co/t/cpu-affinity-when-running-multiple-nodes-on-a-single-host/231611/6 "2020-06-05T09:33:28Z")

</div>

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