Does AsyncLocalStorage Affect Performance in High-Traffic Node.js Apps?

May 19, 2025 3 answers
Asked by 3 ducks indoors
I'm thinking about using AsyncLocalStorage from the async_hooks module in my Node.js app, which needs to handle a high volume of traffic—about 20,000 requests per minute. The main purpose is to maintain context throughout requests, like tracking userId and traceId. I'm a bit worried about performance impacts in a high-concurrency setup. Can anyone share their experiences? Has anyone benchmarked this, and if there is a performance hit, what optimizations or alternatives do you recommend?

Answers

~Amateur beekeeper
Why not create a script to simulate 20,000 requests per minute? That way, you can measure the performance impact for yourself!
Reply to this answer
~in other words
It's a mixed bag. We use it too, and while it does bring some performance overhead, it's minor compared to other factors like I/O or network delays. Just don't overuse it!
Reply to this answer
keyboard travel
I really wouldn't recommend using AsyncLocalStorage for your use case. It's best to keep APIs stateless to ensure better scalability.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions