Question 1: Why can CPU-intensive tasks severely degrade Node.js performance?
- They consume too much memory
- They block the event loop
- They crash the V8 engine
- They disable async I/O
Explanation: CPU-heavy tasks block the single-threaded event loop.
This advanced Node.js quiz is designed for senior developers and backend engineers who want to test deep, real-world knowledge. It covers event loop internals, memory management, performance bottlenecks, scaling strategies, security, and production-grade architecture commonly asked in advanced interviews.
Explanation: CPU-heavy tasks block the single-threaded event loop.
Explanation: worker_threads enable multi-threaded JavaScript execution.
Explanation: cluster creates processes, worker_threads create threads.
Explanation: setImmediate runs in the check phase.
Explanation: process.nextTick can starve the event loop.
Explanation: Backpressure prevents overwhelming memory.
Explanation: Duplex streams support both reading and writing.
Explanation: Streams handle data in chunks.
Explanation: libuv powers the event loop and async operations.
Explanation: Uncleared timers retain memory references.
Explanation: Global references prevent garbage collection.
Explanation: Chrome DevTools can profile Node.js memory.
Explanation: It means V8 heap memory is exhausted.
Explanation: This flag increases the V8 heap size.
Explanation: Parsing large JSON blocks the event loop.
Explanation: Content-Length helps validate request size.
Explanation: Synchronous fs blocks the event loop.
Explanation: Slow requests can block the event loop.
Explanation: Rate limiting prevents abuse.
Explanation: Clustering with load balancing enables scaling.
Explanation: Sticky sessions route users to the same worker.
Explanation: Shared memory can cause race conditions.
Explanation: Graceful shutdown closes resources properly.
Explanation: SIGTERM allows cleanup before exit.
Explanation: Secrets in code can be leaked.
Explanation: The vm module isolates execution contexts.
Explanation: Lag indicates blocking or heavy CPU usage.
Explanation: Event loop latency measures responsiveness.
Explanation: bcrypt is CPU-heavy.
Explanation: fs and crypto use the libuv thread pool.
Explanation: Tasks wait until threads are free.
Explanation: UV_THREADPOOL_SIZE configures the pool.
Explanation: V8 GC handles objects efficiently.
Explanation: Fail-fast allows recovery via restarts.
Explanation: They can leave the process in an inconsistent state.
Explanation: Restart ensures clean state.
Explanation: Stateless services scale easily.
Explanation: Proper validation prevents attacks.
Explanation: Nginx offloads networking concerns.
Explanation: Compression is CPU-intensive.
Explanation: Async structured logging scales well.
Explanation: Idempotency avoids duplicate operations.
Explanation: PUT is idempotent.
Explanation: Node.js excels at scalable I/O.
Explanation: Monitoring and graceful shutdown are essential.
This advanced Node.js quiz is designed for senior developers and backend engineers who want to test deep, real-world knowledge. It covers event loop internals, memory management, performance bottlenecks, scaling strategies, security, and production-grade architecture commonly asked in advanced interviews.