Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    KEA Multi-Threading - reduce number of threads

    Scheduled Pinned Locked Moved DHCP and DNS
    13 Posts 5 Posters 124 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 4 Offline
      4o4rh
      last edited by

      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
      },

      AndyRHA 1 Reply Last reply Reply Quote 0
      • AndyRHA Offline
        AndyRH @4o4rh
        last edited by

        @4o4rh For my own knowledge, why would you want to reduce the threads?

        o||||o
        7100-1u

        4 1 Reply Last reply Reply Quote 0
        • 4 Offline
          4o4rh @AndyRH
          last edited by

          @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.

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            SteveITS Rebel Alliance @4o4rh
            last edited by

            @4o4rh It shouldn't really be using notable CPU.

            A guess, are you seeing kea2unbound usage? Set pfBlocker to python mode.

            Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
            When upgrading, allow 10-15 minutes to reboot, or more depending on packages, and device or disk speed.
            Upvote ๐Ÿ‘ helpful posts!

            4 2 Replies Last reply Reply Quote 0
            • 4 Offline
              4o4rh @SteveITS
              last edited by

              @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

              GertjanG 1 Reply Last reply Reply Quote 0
              • 4 Offline
                4o4rh @SteveITS
                last edited by

                @SteveITS i can confirm, editing /usr/local/etc/kea/kea-dhcp4.conf results in the changes being overwritten after reboot.

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  SteveITS Rebel Alliance @4o4rh
                  last edited by

                  @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.

                  Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
                  When upgrading, allow 10-15 minutes to reboot, or more depending on packages, and device or disk speed.
                  Upvote ๐Ÿ‘ helpful posts!

                  4 2 Replies Last reply Reply Quote 0
                  • 4 Offline
                    4o4rh @SteveITS
                    last edited by

                    @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

                    1 Reply Last reply Reply Quote 0
                    • 4 Offline
                      4o4rh @SteveITS
                      last edited by 4o4rh

                      @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.

                      1 Reply Last reply Reply Quote 2
                      • P Online
                        psp
                        last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • GertjanG Offline
                          Gertjan @4o4rh
                          last edited by Gertjan

                          @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 :

                          b99f54c5-9416-441f-b514-e4abf80c04c4-image.png

                          ?

                          Add your 'extra' settings there !
                          Like this :

                          38f53fd7-455a-4c9f-810e-02fb47e714ce-image.png

                          {
                            "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 :

                          43066999-3b59-498d-8a1d-714514b42677-image.png

                          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.

                          No "help me" PM's please. Use the forum, the community will thank you.
                          Edit : and where are the logs ??

                          4 1 Reply Last reply Reply Quote 0
                          • 4 Offline
                            4o4rh @Gertjan
                            last edited by

                            @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

                            GertjanG 1 Reply Last reply Reply Quote 0
                            • GertjanG Offline
                              Gertjan @4o4rh
                              last edited by

                              @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.

                              No "help me" PM's please. Use the forum, the community will thank you.
                              Edit : and where are the logs ??

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.