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?
3 Answers
I really wouldn't recommend using AsyncLocalStorage for your use case. It's best to keep APIs stateless to ensure better scalability.
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!
Why not create a script to simulate 20,000 requests per minute? That way, you can measure the performance impact for yourself!
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String