I'm working with rlm_python in FreeRadius 2.2.6 and with 20 simultaneous eapol_test threads running I was only getting 5-6 requests/second. This got me wondering how FreeRadius and rlm_python handle threading. So to make sure it wasn't related to my database calls or anything else I wrote a simple radiusd_module.py with no external dependencies/calls that instantly returned OK and it was handling 275 requests/second. Now I'm doubting my requests are being processed in parallel so I modified my radiusd_module.py to have a 1 second sleep between starting to process a request and returning OK. The module looks something like this: import radiusd import time def instantiate(p): # do something return 0 def array_to_dict(array): my_dict = {} for t in array: # strip any quotes off of the beginning & end my_dict[t[0]] = t[1].lstrip('"').rstrip('"') return my_dict def post_auth(p): my_dict = array_to_dict(p) print "***** Start %s" % my_dict['NAS-Port-Id'] time.sleep(1) print "***** End %s" % my_dict['NAS-Port-Id'] return radiusd.RLM_MODULE_OK Then I set two copies of eapol_test in an infinite loop sending NAS-Port-Id's of 1 and 2 so I could see what radius.log looked like. The hypothesis being if it's properly threaded I should get this: ***** Start 1 ***** Start 2 ==== Pause 1 second ***** End 1 ***** End 2 ... repeat I ran the the two eapol_test threads against radius and the output looks like this: tail radius.log -f | grep "\*\*\*\*\*" ***** Start 1 ==== Pause 1 second <-- not output, just a literal 1 second wait from time.sleep() ***** End 1 ***** Start 2 ==== Pause 1 second <-- not output, just a literal 1 second wait from time.sleep() ***** End 2 .... and so on,
From this I can see that requests handled by rlm_python are being served by a single thread rather than multiple/parallel threads. Does anybody have any experience with rlm_python.py and/or know what I might be doing wrong?
Thanks! Andrew P.S. Latency from my development machine at my desk to Dynamodb in AWS is ~80ms, **which won't be the case for prod**, which is why I was only getting 5-6 requests/second. but I'd still like to be able to handle hundreds of requests/s per production host (obviously the hosts will need to be sized appropriately).
From this I can see that requests handled by rlm_python are being served by a single thread rather than multiple/parallel threads. Does anybody have any experience with rlm_python.py and/or know what I might be doing wrong?
The rlm_python module is not thread safe in v2.x.x. It is(ish) in v3.0.x. Though there have been reports of crashes YMMV. The python docs in this area are terrible. If you can fix threading so it works correctly in v3.0.x, and send a pull request it'd be much appreciated. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 25/03/15 02:32, Arran Cudbard-Bell wrote:
From this I can see that requests handled by rlm_python are being served by a single thread rather than multiple/parallel threads. Does anybody have any experience with rlm_python.py and/or know what I might be doing wrong?
The rlm_python module is not thread safe in v2.x.x.
It is(ish) in v3.0.x. Though there have been reports of crashes YMMV.
The python docs in this area are terrible.
Yeah. Calling into an embedded python interpreter from >1 thread is hard to get right. It's probably not a great fit for embedding into a threaded server like FreeRADIUS, and I say that as a big fan of the language. It's possible PyPy will eventually solve this, although it's a way off being ready for that use-case AFAICT.
participants (3)
-
Andrew Parisio -
Arran Cudbard-Bell -
Phil Mayers