rlm_perl multiple processes/threads behavior

Iliya Peregoudov iperegudov at cboss.ru
Thu Sep 18 08:25:28 CEST 2014


rlm_perl had never spawn perl processes. rlm_perl embeds perl into the 
radiusd process space, so no inter-process communication is needed to 
call perl functions.

rlm_perl in freeradius 1.1 uses pool of interpreters. radiusd thread 
take first unused interpreter from pool when rlm_perl is entered and put 
the interpreter back to the pool when rlm_perl is leaved.

rlm_perl in freeradius 2.1 or higher uses interpreter per thread model. 
When the thread enters the rlm_perl for first time the interpreter is 
allocated and tied to the thread.

Perl interpreter allocation is only used when perl library is compiled 
with USE_ITHREADS. If no USE_ITHREADS, then module is marked as thread 
unsafe when built. freeradius core ensures not to call rlm_perl instance 
in multiple threads simultaneously and rlm_perl instance uses single 
interpreter.

If you want single rlm_perl instance to be called simultaneously from 
different thread you need perl built with USE_ITHREADS.

However you can always call multiple rlm_perl instances simultaneously. 
Define multiple perl instances with same script, and call them from 
load-balance group:

module pl1 {
   module = ${confdir}/pl.pl
}
module pl2 {
   module = ${confdir}/pl.pl
}
module pl3 {
   module = ${confdir}/pl.pl
}
module pl4 {
   module = ${confdir}/pl.pl
}

authorize {
   load-balance {
     pl1 # 25% of requests go here
     pl2
     pl3
     pl4
   }
}


On 16.09.2014 22:20, Nick Rogers wrote:
> Hello,
>
> I am hoping someone can clarify some questions I have about how rlm_perl
> should behave in FreeRADIUS 2.2.5 with respect to multiple instances and
> freeradius threads. I know there has been some discussion and
> changes/fixes to this behavior over the years, and I've been using
> rlm_perl successfully for nearly the last decade. Previously rlm_perl
> had its own "thread" pool, where multiple instances of the perl process
> would run simultaneously. Now I understand that rlm_perl uses the same
> freeradius thread management that everything else does.
>
> My problem is that my freeradius rlm_perl installation no longer spawns
> multiple instances of the perl process, effectively causing my server to
> be single threaded, which has begun to cause performance issues at some
> of my larger sites with increased load.
>
> I do not have perl with multiplicity or ithreads compiled, as this
> causes issues with other perl applications running on the same server.
> My question is, is there a way to support multiple instances of the
> rlm_perl interpreter without having ithreads or multiplicity compiled
> with perl?
>
> Is there a way for freeradius to simply launch a perl process for every
> freeradius server thread, instead of all threads relying on the same
> rlm_perl process? I am not interested in using perl threads or having
> multiple perl interpreters within the same perl process. I would really
> appreciate some clarification if this is possible or not.
>
> Thanks!
>
> -Nick



More information about the Freeradius-Users mailing list