question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad performance of getAccountByHomeId with persistance (redis) storage

See original GitHub issue

Core Library

MSAL Node (@azure/msal-node)

Wrapper Library

MSAL Node Extensions (@azure/msal-node-extensions)

Public or Confidential Client?

Confidential

Description

When trying to implement redis cache, we realised really bad performance:

getAccountByHomeId is loading all accounts from storage (in our case redis) and then doing an Array.find in nodejs. This approach works, however with several hundreds logins stored in single key in redis, it pulls all from redis in database (could be several megs of data) and then performs quite expensive filter in memory. As result of this the servers might suffer with big RAM / CPU spikes.

https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/cache/TokenCache.ts#L129

in case of external storage it would be better to allow search in external storage by key by passing home id to beforeCacheAccess function and use advantage of search in external storage, instead of doing this in memory.

Source

External (Customer)

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
derisencommented, Dec 1, 2022

@petermilan indeed, performance wise it would be better to scope the msal instance to each request and load only the current users cache into the memory -did you had a chance to see the RedisTestApp sample?

0reactions
msftbot[bot]commented, Dec 20, 2022

@petermilan This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis persistence
Persistence refers to the writing of data to durable storage, such as a solid-state disk (SSD). Redis provides a range of persistence options....
Read more >
Performance Tuning for Redis | Severalnines
In this blog, we'll go through the important flows for tuning your Redis performance. Memory management. Redis is an in-memory data store with ......
Read more >
Understanding the Top 5 Redis Performance Metrics - Datadog
Despite being an in-‐memory data store, Redis can persist its data to disk for durability. Persistence is the ability for a process to...
Read more >
Does Redis persist data? - Stack Overflow
Redis isn't the best fit for persistent storage as it's mainly performance focused; Redis is really more suitable for reliable in-memory storage ...
Read more >
Redis Persistence Deep Dive - Memurai
For the purpose of this article, persistence refers to the mechanism used to persist data stored in memory to the host's file system....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found