# Setting CPU affinity for fdbservers

**URL:** <https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84>\
**Category:** Using FoundationDB\
**Created:** [April 19, 2018, 10:52pm UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84 "2018-04-19T22:52:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cespare](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/cespare/32/36_2.png) [@cespare](https://forums.foundationdb.org/u/cespare)\
**Post date:** [April 19, 2018, 10:52pm UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84/1 "2018-04-19T22:52:03Z")

</div>

I’m reading [this documentation](https://apple.github.io/foundationdb/administration.html#fdbmonitor-and-fdbserver) and it says

> The core FoundationDB server process is fdbserver. Each fdbserver process uses up to one full CPU core, so a production FoundationDB cluster will usually run N such processes on an N-core system.
> 
> To make configuring, starting, stopping, and restarting fdbserver processes easy, FoundationDB also comes with a singleton daemon process, fdbmonitor, which is started automatically on boot. […]

Does fdbmonitor pin fdbserver processes to CPUs? From poking around the code, it seems like the answer is no.

I would think that this is important for best performance. At our company we run a large cluster of redis servers, which are also single-threaded, and in order to maximize throughput and minimize latency we have to pin each redis-server process to a dedicated CPU and also pin NIC rx queue IRQs to different CPUs.

(And on large machines with multiple NUMA nodes it seems even more important to ensure that at least each server process is pinned to a single node so that it cannot allocate memory on the wrong domain.)

Does this concern make sense, or have I misunderstood something? Are these features which fdbmonitor could add one day, or is the idea that in certain cases FDB users ought not to use fdbmonitor and should run the fdbservers according to their particular needs?

---

<div class="post-metadata">

**Author:** ![alexmiller](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alexmiller/32/326_2.png) [@alexmiller](https://forums.foundationdb.org/u/alexmiller)\
**Post date:** [April 19, 2018, 11:19pm UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84/2 "2018-04-19T23:19:21Z")

</div>

No, I agree that the code appears it does not. It looks like once upon a time the resolver tried to be CPU/NUMA-aware to some degree, but it was commented out. It’s worth considering doing, and I’ve filed [issue 196](https://github.com/apple/foundationdb/issues/196) to track it. Though isolating low latency processes and network interrupts is a good idea, I’m not clear that having fdbmonitor change to which core NIC IRQs are sent wouldn’t be seen as surprising behavior.

Thanks!

---

<div class="post-metadata">

**Author:** ![cespare](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/cespare/32/36_2.png) [@cespare](https://forums.foundationdb.org/u/cespare)\
**Post date:** [April 19, 2018, 11:36pm UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84/3 "2018-04-19T23:36:21Z")

</div>

> I’m not clear that having fdbmonitor change to which core NIC IRQs are sent wouldn’t be seen as surprising behavior.

Oh yeah, I definitely agree that fdbmonitor shouldn’t be doing that. (And on a lot of Linux systems it would just be fighting with irqbalance anyway.) I just brought it up as an example of the types of stuff that might all have to be coordinated together.

Therefore it seems like having a way to tell fdbmonitor which CPUs it should be using would be best. Then I can pin NIC IRQs elsewhere and also possibly isolcpus all of these cores.

---

<div class="post-metadata">

**Author:** ![Ramaprakash](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Ramaprakash](https://forums.foundationdb.org/u/Ramaprakash)\
**Post date:** [April 20, 2018, 4:40pm UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84/4 "2018-04-20T16:40:44Z")

</div>

We should also increase the priority, that way non priority process does not kick out the fob server process.

---

<div class="post-metadata">

**Author:** ![panghy](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/panghy/32/19_2.png) [@panghy](https://forums.foundationdb.org/u/panghy)\
**Post date:** [November 18, 2018, 1:24am UTC](https://forums.foundationdb.org/t/setting-cpu-affinity-for-fdbservers/84/5 "2018-11-18T01:24:39Z")

</div>

Just commented on the issue, we do see significant improvements to hot spots in the cluster when processes are pegged with numactl.
