Python Module Threading Issue

classic Classic list List threaded Threaded
2 messages Options
| Threaded
Open this post in threaded view
|

Python Module Threading Issue

Kwak Wookjong-2
Hi Alan,

I recently upgraded FreeRadius server 3.0.16 to 3.0.19 and observed a performance issue on handling multiple thread.

I have done some research on this forum and found below discussion for Python Module Threading Issue about a year ago.
http://freeradius.1045715.n5.nabble.com/Python-Module-Threading-Issue-td5751186.html#a5751236<http://freeradius.1045715.n5.nabble.com/Python-Module-Threading-Issue-td5751186.html%23a5751236>

As a result of the discussion, it made one of the configuration value changed in rlm_python/rlm_pyton.c (line #1180) for 3.0.18 release.
https://github.com/FreeRADIUS/freeradius-server/commit/9a9e7852e52cab5323df87caca28a12f3459da88#diff-2744f0b518da3a53f09cbbbf449f14e9<https://github.com/FreeRADIUS/freeradius-server/commit/9a9e7852e52cab5323df87caca28a12f3459da88%23diff-2744f0b518da3a53f09cbbbf449f14e9>
module_t rlm_python = {
               .magic                  = RLM_MODULE_INIT,
               .name                   = "python",
-              .type                     = RLM_TYPE_THREAD_SAFE,
+             .type                     = RLM_TYPE_THREAD_UNSAFE,

and it looked like the change was made in case for using multiple python modules but the thing is,
in my case, within a single python module the multiple requests were treated as a single threaded.

I have confirmed such behavior with a simple test with using python module and example code provided in /etc/raddb/mods-config/python/example.py
by putting few seconds of delay for authenticate.

def authenticate(p):
  print "*** authenticate ***"
  time.sleep(5)
  return radiusd.RLM_MODULE_OK

Also confirmed, by putting back RLM_TYPE_THREAD_SAFE, multiple requests were handled by multi-threaded and the performance issue was resolved.

If it were needed to update RLM_TYPE_THREAD_UNSAFE for using multiple python module,
Can you, at least, make it configurable so that it can be set depending on the usage and situation?

Let me know,

Thanks!

Best Regards,
wj

________________________________
This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
| Threaded
Open this post in threaded view
|

Re: Python Module Threading Issue

Alan DeKok-2
On Sep 5, 2019, at 5:07 PM, Kwak Wookjong <[hidden email]> wrote:
> I recently upgraded FreeRadius server 3.0.16 to 3.0.19 and observed a performance issue on handling multiple thread.
>
> I have done some research on this forum and found below discussion for Python Module Threading Issue about a year ago.
> http://freeradius.1045715.n5.nabble.com/Python-Module-Threading-Issue-td5751186.html#a5751236<http://freeradius.1045715.n5.nabble.com/Python-Module-Threading-Issue-td5751186.html%23a5751236>

  Which points to this:

https://docs.python.org/2/c-api/init.html

> and it looked like the change was made in case for using multiple python modules but the thing is,
> in my case, within a single python module the multiple requests were treated as a single threaded.

  The change was made because the Python interpreter isn't thread-safe.  Even for one module.

> Also confirmed, by putting back RLM_TYPE_THREAD_SAFE, multiple requests were handled by multi-threaded and the performance issue was resolved.

  And it will randomly crash due to threading issues.

> If it were needed to update RLM_TYPE_THREAD_UNSAFE for using multiple python module,
> Can you, at least, make it configurable so that it can be set depending on the usage and situation?

  We don't like the server crashing, sorry.

  If it seems to work for you, you can always make local changes on your system to build it with the THREAD_SAFE flag.

  Alan DeKok.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html