Skip to content

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

  1. How does Node.js achieve concurrency despite being single-threaded?
  2. What are the responsibilities of libuv?
  3. Explain the difference between the call stack, event loop, and threadpool.
  4. When does Node spawn additional threads?
  5. 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() vs queueMicrotask()
  • setTimeout() vs setImmediate()

Sample Questions

  1. Name and describe all 6 phases of the Node.js event loop.
  2. When are microtasks executed in Node.js?
  3. Why does process.nextTick run before all microtasks?
  4. What’s the difference between setImmediate and setTimeout(..., 0)?
  5. 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.cache internals
  • Node resolution algorithm

Sample Questions

  1. How does Node resolve modules internally?
  2. Why do circular imports cause unexpected behavior?
  3. What is the difference between ESM and CommonJS in Node.js?
  4. How does require.cache work?

4. Streams & Backpressure

Concepts

  • Readable, Writable, Duplex, Transform
  • Flowing vs paused mode
  • Backpressure and drain events

Sample Questions

  1. Explain how streams work internally.
  2. What is backpressure and how does Node manage it?
  3. Why are streams preferred over reading entire files into memory?
  4. How do you pipe streams manually?

5. Buffers & Binary Data

Topics

  • Memory allocation in buffers
  • Little endian vs big endian
  • Buffer.alloc() vs Buffer.allocUnsafe()

Sample Questions

  1. Why does Node.js have Buffer? Why not use TypedArrays only?
  2. How is memory allocated for Buffers?
  3. What’s the difference between alloc and allocUnsafe?

6. Networking & HTTP Internals

Topics

  • HTTP keep-alive
  • Chunked transfer encoding
  • Handling high concurrency
  • Reverse proxies (Nginx)

Sample Questions

  1. How does Node handle thousands of concurrent connections?
  2. What is HTTP keep-alive and why is it important in Node?
  3. Why do we often put Nginx in front of Node?
  4. How do you prevent slowloris attacks?

7. Concurrency & Scaling

Topics

  • Cluster module
  • Worker Threads
  • Message passing
  • Horizontal scaling

Sample Questions

  1. Node is single-threaded—so what is the cluster module for?
  2. When should you use worker threads over clustering?
  3. 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

  1. Why should database queries never block the event loop?
  2. How do connection pools work in Node?
  3. What caching layers work well with Node?

9. Performance & Debugging

Tools

  • Node Inspector
  • --inspect flag
  • Flamegraphs
  • Heap snapshots
  • clinic.js

Sample Questions

  1. How do you detect memory leaks in Node.js?
  2. How do you profile CPU-bound tasks?
  3. What tools does Node provide for debugging?
  4. Why does a long synchronous task crash performance?

10. Production Concerns

Topics

  • PM2 / systemd
  • Zero-downtime deployments
  • Graceful shutdown
  • Health checks
  • Logging

Sample Questions

  1. How do you gracefully shut down a Node server?
  2. Why should you handle SIGTERM and SIGINT events?
  3. How do you rotate logs in Node?
  4. Why do we use PM2 in production?

11. Security (Node-Specific)

Topics

  • Prototype pollution
  • SSRF (server-side)
  • Secrets management

Sample Questions

  1. What is prototype pollution in Node? How do you mitigate it?
  2. How do you safely parse JSON input?
  3. 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

Maintained by OfficialCTO — © 2025 Official CTO.