I'm thinking about implementing AsyncLocalStorage from the async_hooks module in my Node.js application. This app needs to handle a high volume of traffic—about 20,000 requests per minute—while keeping track of user IDs, trace IDs, and other context information across requests. I'm really cautious about this decision and would like to know if using AsyncLocalStorage could negatively affect performance, especially in high-concurrency situations. Has anyone benchmarked this or has real-world insights? If there are potential performance downsides, are there optimization strategies or better alternatives to consider? Any advice would be greatly appreciated!
2 Answers
I would really recommend against using AsyncLocalStorage for maintaining context. Ideally, your API should remain stateless, which is more efficient in high-traffic scenarios.
{
I've actually used AsyncLocalStorage in a clustered environment, and it worked well for me. Could you explain your concerns about it being stateless?