You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, we are using ConfidentialClientApplication via MSAL python package. In production we see that it takes around 2 seconds (P90) to create the class. We want to avoid caching since the class is heavy. Is there a workaround or usage hack to cut the latency time ?
Why did you say "in production ... it takes around 2 seconds"? Was it faster when running in your local develop machine? If this happens to be the case, you need to look into the differences in your prod and local environment setup. You could enable debug logs to help profiling MSAL in your app.
In general, MSAL is not currently designed to lazy load most of its prerequisites, so the initialization time is not blazingly fast. By designing MSAL as an Object-Oriented API model (rather than a function-based API), the implication is that the caller would ideally keep a long-lived ConfidentialClientApplication (or PublicClientApplication, for that matter), and stick with such a calling pattern:
app = ConfidentialClientApplication(...)
# Per each request
app.acquire_token_silent(...)
app.acquire_token_by_xyz(...)
... # etc.
If you can do so, then the relatively longer initialization time should not be a real issue.
There are situations that your entire application would be short-lived, such as a command-line script. MSAL Python recently introduced a customizable http cache mechanism, so that a CLI app can still reuse some initialization effort performed by its previous run. You can search keyword "http_cache (dict)" in our online API Reference doc for details.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey, we are using
ConfidentialClientApplication
via MSAL python package. In production we see that it takes around 2 seconds (P90) to create the class. We want to avoid caching since the class is heavy. Is there a workaround or usage hack to cut the latency time ?Beta Was this translation helpful? Give feedback.
All reactions