Node.js Interview Questions & Deep-Dive Topics
This article focuses exclusively on Node.js — its runtime, internals, concurrency model, performance characteristics, APIs, modules, architecture, and ecosystem. It is designed for backend and full‑stack engineers preparing for Node.js-specific roles.
1. Node.js Architecture Fundamentals
Key Concepts
- Single-threaded JavaScript execution
- libuv event loop
- Worker threads vs threadpool
- C++ bindings, V8 engine
- Non-blocking I/O
Sample Questions
- How does Node.js achieve concurrency despite being single-threaded?
- What are the responsibilities of libuv?
- Explain the difference between the call stack, event loop, and threadpool.
- When does Node spawn additional threads?
- Why is Node.js great for I/O-bound workloads but poor for CPU-bound workloads?
2. Node.js Event Loop Internals
Must-Know Topics
- The 6 phases of the Node event loop
- Microtasks vs macrotasks
process.nextTick()vsqueueMicrotask()setTimeout()vssetImmediate()
Sample Questions
- Name and describe all 6 phases of the Node.js event loop.
- When are microtasks executed in Node.js?
- Why does
process.nextTickrun before all microtasks? - What’s the difference between
setImmediateandsetTimeout(..., 0)? - How does promise resolution fit into the event loop?
3. Modules & Package System
Topics
- CommonJS vs ESM in Node.js
- Deadlocks in circular requires
require.cacheinternals- Node resolution algorithm
Sample Questions
- How does Node resolve modules internally?
- Why do circular imports cause unexpected behavior?
- What is the difference between ESM and CommonJS in Node.js?
- How does
require.cachework?
4. Streams & Backpressure
Concepts
- Readable, Writable, Duplex, Transform
- Flowing vs paused mode
- Backpressure and drain events
Sample Questions
- Explain how streams work internally.
- What is backpressure and how does Node manage it?
- Why are streams preferred over reading entire files into memory?
- How do you pipe streams manually?
5. Buffers & Binary Data
Topics
- Memory allocation in buffers
- Little endian vs big endian
Buffer.alloc()vsBuffer.allocUnsafe()
Sample Questions
- Why does Node.js have Buffer? Why not use TypedArrays only?
- How is memory allocated for Buffers?
- What’s the difference between
allocandallocUnsafe?
6. Networking & HTTP Internals
Topics
- HTTP keep-alive
- Chunked transfer encoding
- Handling high concurrency
- Reverse proxies (Nginx)
Sample Questions
- How does Node handle thousands of concurrent connections?
- What is HTTP keep-alive and why is it important in Node?
- Why do we often put Nginx in front of Node?
- How do you prevent slowloris attacks?
7. Concurrency & Scaling
Topics
- Cluster module
- Worker Threads
- Message passing
- Horizontal scaling
Sample Questions
- Node is single-threaded—so what is the cluster module for?
- When should you use worker threads over clustering?
- How do you scale a Node server across 8 cores?
8. Databases & I/O Patterns
Topics
- Connection pooling
- Async DB drivers
- Caching strategies
Sample Questions
- Why should database queries never block the event loop?
- How do connection pools work in Node?
- What caching layers work well with Node?
9. Performance & Debugging
Tools
- Node Inspector
--inspectflag- Flamegraphs
- Heap snapshots
clinic.js
Sample Questions
- How do you detect memory leaks in Node.js?
- How do you profile CPU-bound tasks?
- What tools does Node provide for debugging?
- Why does a long synchronous task crash performance?
10. Production Concerns
Topics
- PM2 / systemd
- Zero-downtime deployments
- Graceful shutdown
- Health checks
- Logging
Sample Questions
- How do you gracefully shut down a Node server?
- Why should you handle
SIGTERMandSIGINTevents? - How do you rotate logs in Node?
- Why do we use PM2 in production?
11. Security (Node-Specific)
Topics
- Prototype pollution
- SSRF (server-side)
- Secrets management
Sample Questions
- What is prototype pollution in Node? How do you mitigate it?
- How do you safely parse JSON input?
- Where should secrets be stored in a Node app?
12. Coding Tasks (Node.js Specific)
- Build a streaming file uploader
- Implement a TCP server using
net - Implement a simple job queue
- Create a CLI tool
- Build a rate limiter (token bucket or sliding window)
- Wrap a callback API into a Promise
13. Take‑Home Assignments
- Build a file upload microservice using streams + retries
- Build a queue-based job processor with concurrency controls
- Build an Express/Koa API with caching & pagination
- Create a simple message broker using TCP sockets