FreeRADIUS Thread Behavior

Doug Wussler doug.wussler at fsu.edu
Mon Oct 16 22:07:19 CEST 2017


Doug says:
- The question I am trying to answer is why the threads turn over at all, and in particular
so frequently.  Here is my config for the settings I thought control the thread behavior:
From “radiusd.conf”
# THREAD POOL CONFIGURATION
thread pool {
        start_servers = 8
        max_servers = 32
        min_spare_servers = 2
        max_spare_servers = 8

Alan replies:
i.e. if there are more than 8 spare threads, one is deleted.  If there are fewer than 2 spare threads, one is created.

Doug says:
Have I overlooked a setting or misunderstood the way these settings work?

Alan replies:
Again, the documentation is VERY clear on this:

                #  It does this by periodically checking how many servers are
                #  waiting for a request.  If there are fewer than
                #  min_spare_servers, it creates a new spare.  If there are
                #  more than max_spare_servers, some of the spares die off.

Doug responds:
Yes, I agree the doc is clear.  That is my point, I do not see my system behaving like the doc describes, or
at least how one would expect it to behave.  Further testing indicates the thread testing loop behaves like this:
                Check if idle threads are less than min.
                     Always find fewer than min spare threads so spawn more idle threads.
              Check to see if idle threads are more than max.
                    Always find more idle threads than max so kill oldest threads.
              Rest
             Return to beginning.

One iteration of the loop happens so fast that, if you look, you almost never see the newly spawned spare threads along
with the full set of threads that were just tested for idleness.  Right after the new threads are spawned,
older ones are terminated.  Not only are threads being unintentionally retired and spawned, the LDAP
and SQL connections are lost and must be restarted too.

So, I’m not complaining, I just thought you would want to know.  As you say, you could set:

     start_servers = n
     max_servers = n
     max_spare_servers = n
     min_spare_servers = 0

and that will put a stop to the unwanted dying and spawning of threads.  This seems like an approach to
be vastly preferred over the way the current non-zero spare thread implementation is working, even if it wastes
some resources.

However, to minimize wasted resources while ensuring peak demands are met,
one first needs to determine a “good” number for n for their particular server, and, more
importantly, it remains to be seen if threads that never die are subject to some sort of memory leakage
or data-structure corruption between server reboots (which for us is daily at log-rotate time).

Doug

Doug Wussler
850.645.4201
Florida State University
RK Shaw Building
644 W. Call Street
Tallahassee, FL  32304



More information about the Freeradius-Users mailing list