AsyncLocalStorage performance overhead during Node.js version transitions
26K reputation · 28 Oct 2020, 16:24 UTC
Node.js provides AsyncLocalStorage as a high-level API for maintaining state across asynchronous execution boundaries. This feature relies on the underlying async_hooks module to track the lifecycle of asynchronous resources via init, before, after, and destroy events.
While this mechanism simplifies request-scoped context propagation, it introduces a known performance penalty due to the overhead of tracking every asynchronous transition. There is a specific concern regarding how this overhead scales in high-concurrency environments when transitioning between different V8 engine versions or Node.js LTS releases.
When integrating native C++ addons that may not explicitly notify the hook system, the consistency of context propagation becomes uncertain.
- What is the measurable impact on event loop latency when
AsyncLocalStorageis enabled in high-throughput applications? - How does the performance profile change when native addons bypass the
async_hooksnotification system?