KEA Multi-Threading - reduce number of threads
-
It seems multi-threading is enabled by default, as i can't find a specific setting for it. In my case it is default to a thread pool size of 4 which is overkill for my network. what is the correct way to insert
"multi-threading": {
"enable-multi-threading": true,
"thread-pool-size": 2,
"packet-queue-size": 64
}, -
@4o4rh For my own knowledge, why would you want to reduce the threads?
-
@AndyRH I have a low-end CPU Intel i3-8130U, 2 cores / 4 threads
If defaults to using 4 threads, two per core, which saturates the CPU for little to no gain. My home network can probably more than suffice with a single thread, so I want to reduce in two steps. -
@4o4rh It shouldn't really be using notable CPU.
A guess, are you seeing kea2unbound usage? Set pfBlocker to python mode.
-
@SteveITS Hi Steve, the log is showing below.
It seems that it is using that by default.
Oct 14 19:40:17 kea-dhcp4 25524 WARN [kea-dhcp4.dhcp4.0x2fcfd0e12000] DHCP4_MULTI_THREADING_INFO enabled: yes, number of threads: 4, queue size: 64
I can modify it, per the below
sed -i '/"Dhcp4": {/a\ "multi-threading": { "enable-multi-threading": true, "thread-pool-size": 2, "packet-queue-size": 64 },' /usr/local/etc/kea/kea-dhcp4.conf
But I want to do it in a way that is persistent through upgrades
-
@SteveITS i can confirm, editing /usr/local/etc/kea/kea-dhcp4.conf results in the changes being overwritten after reboot.
-
@4o4rh You still haven't said why you think CPU usage is a problem...
In general with pfSense manually edited configurations are always overwritten by the configuration file. If everything is in the config file then it is portable to a new router.
At the bottom of https://docs.netgate.com/pfsense/en/latest/services/dhcp/kea-settings.html did you find the note about:
"See the following forum thread for configuration snippet examples and discussion: https://forum.netgate.com/topic/196513/adding-custom-configuration-in-kea-dhcp-server-with-pfsense-25-03"? Maybe that will help. -
@SteveITS Intel i3-8130U (2 cores / 4 threads) is a low-power dual-core CPU, but it handles multi-threaded network daemons like Kea quite well โ as long as you size thread pools carefully.
Clients / Requests per second Recommended threads <100 (home/small office) 1โ2 100โ1000 2 >1000 (ISP / campus) 4โ8 (on bigger CPUs)
Unfortunately, your suggestion doesn't work as the code has to go under dhcp4
"Dhcp4": { "multi-threading": { "enable-multi-threading": true, "thread-pool-size": 2, "packet-queue-size": 64 }, "interfaces-config": { ...... }
I am pretty sure my system will more than suffice with a pool size of 1
-
@SteveITS that's weird. The first time I tried to add in the json section, it didn't work. Hence, I created the post. Just tried it again, and it worked. Must have had a typo or something on the original attempt
{ "multi-threading": { "enable-multi-threading": true, "thread-pool-size": 2, "packet-queue-size": 64 } }
p.s. I've actually decided to switch multithreading off on my small home network to save memory.
-
This post is deleted! -
@4o4rh said in KEA Multi-Threading - reduce number of threads:
I can modify it, per the below
sed -i '/"Dhcp4": {/a\ "multi-threading": { "enable-multi-threading": true, "thread-pool-size": 2, "packet-queue-size": 64 },' /usr/local/etc/kea/kea-dhcp4.conf
But I want to do it in a way that is persistent through upgrades
Modifying a process's config file is, when using pfSense, useless, as these files are rebuild every time a process is started (or restarted).
Rebuild with the info coming from the one-and-only master config file : the collection of settings maintained and build by the pfSense GUI. And who enters all this settings in the GUI : you, the admin.Looking at, for example, /usr/local/etc/kea/kea-dhcp4.conf, some settings have their values set in the GUI.
As you don't change a 'hard coded' GUI settings (I couldn't find any "multi-threading" settings in the GUI code, so no "multi-threading" in the kea-dhcp4.conf file neither) you have this possibility : you saw this on then Services > DHCP Server > Settings page :?
Add your 'extra' settings there !
Like this :{ "multi-threading": { "enable-multi-threading": true, "thread-pool-size": 2, "packet-queue-size": 64 } }
Save the settings - and Apply. Check that you did not receive any System notifications ! Check the DHCP server lof for a clean restart without error message from the DHCP4 process.
Now check your /usr/local/etc/kea/kea-dhcp4.conf, and check if your settings are there.
I found them at the end of the file.Be aware : one space off, one little 'syntax error' and the DHCP config file checker refuses to accept your settings.
Btw : I'm using pfSense Plus 25.07.1 and I see this :
which means 2 for "thread-pool-size", not 4.
Maybe the dhcp kea4 process auto determines the thread pool size itself. for Example, with 8 Gbytes of RAM it uses 4, otherwise 2. -
@Gertjan you must have answered at the same time as Ianswered. The problem was I had a malformed json. I missed the outer {}. It's working now. Thanks
-
@4o4rh said in KEA Multi-Threading - reduce number of threads:
The problem was I had a malformed json
Yeah ... the concept solution is always easy.
Then writing it correctly using the JSON format, that always needs a lot of trial-and-errors before you get it spot-on
I'm adding a lot of settings already in the JSON Configuration bbox, for DHCP options, lease logger options, etc.