AzureAD / azure-activedirectory-library-for-python

ADAL for Python
http://adal-python.readthedocs.io
Other
259 stars 94 forks source link

Removing adal increases webapp latency by 3+ seconds #254

Closed stijntratsaertit closed 2 years ago

stijntratsaertit commented 3 years ago

Hi there,

We are running a Django application which has adal 1.2.1 in it's requirements. Alongside this package, it used to have a ton of other packages which weren't used anymore. I decided to clean that stuff up and when I removed adal from the requirements.txt, I noticed that the API had a big increase in latency. Requests that usually took +-1 second would now take 3, 4 or even much more seconds. Right now, I specifically re-added adal and the latency is back to normal. Now it's just sitting there and it is not used at all, anywhere in the application.

My question is: does anybody have an idea why this happens? Is there anything I can do about it?

Thanks in advance!

rayluo commented 3 years ago

Based on your description, it seems that ADAL's mere presence is actually decreasing your app's latency, rather than increasing it. :-)

Without any details, our guess is your app's other dependency Foo indirectly relies on ADAL Python, possibly a different version. Your explicitly declaring adal==1.2.1 might unwittingly change the ADAL version used by that Foo. But it is still hard to tell.

At this point, you can either profile your webapp to see which function call those latency came from. Or you may spend less effort on just rebuilding your webapp with MSAL Python. We have a sample for that.

stijntratsaertit commented 3 years ago

Thanks for the response! Sorry for the switch around :) It's still strange it has such a big impact on all http routes whilst not using any kind of direct Microsoft integration. As you say, it'll be something that secretly depends on it. But no worries

rayluo commented 3 years ago

it'll be something that secretly depends on it

I forgot to mention, but you could create a fresh virtual environments, install your webapp, without your adal==1.2.1 declaration, and see whether adal is still downloaded, and if so, which version. That way, you would at least know for sure whether something depends on adal. The dependency is not really a secret. They have to declare in a standard way, and you should be able to find it in the console output of your initial pip install -r your_apps_requirements.txt.