D
DevPrepSystematic Prep
NODE.JS · MEDIUM CODEX

Node.js Interview Questions — Medium

Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.

50 Theory Questions7 Implementation Folios5 Free Model Answers
THEORY QUESTIONS & SOLUTIONSShowing 5 of 50 questions
Q1Compare Node's Event-Driven architecture with standard multi-threaded architectures.
  • Multi-threaded (e.g., Tomcat/Java): Allocates a dedicated OS thread per incoming connection. If the thread blocks on database I/O, OS context switches occur, consuming substantial memory (1MB+ per stack) and CPU cycles.
  • Event-Driven (Node.js): Runs on a single main thread using non-blocking system calls. A single process can handle tens of thousands of idle/active connections concurrently because it only executes memory/CPU resources when events occur.
Q2What is the V8 engine's Heap memory structure?
  • Young Generation (New Space): Short-lived objects. Divided into two semi-spaces: To and From. Garbage collection (GC) here is extremely fast (Scavenger).
  • Old Generation (Old Space): Long-lived objects that survived multiple GC runs in the Young Space. Managed by Mark-Sweep-Compact GC algorithm.
  • Large Object Space: Objects exceeding memory limits of other spaces.
  • Code Space: JIT-compiled native code vectors.
  • Map Space: Contains "hidden classes" (shapes) of objects.
Q3How do you configure and debug V8 heap size limits?
  • Argument: Use --max-old-space-size to specify heap limit in megabytes.
  • Example: node --max-old-space-size=4096 app.js (allocates 4GB instead of V8's default 1.4GB on 64-bit systems).
  • Usage: Critical when processing large files, in-memory caches, or running on resource-constrained containers (Docker).
Q4Distinguish between CPU-bound and I/O-bound operations.
  • I/O-bound: Spend most of the execution time waiting for input/output resources (network sockets, database queries, disk reads). Highly optimized in Node.js via non-blocking delegation.
  • CPU-bound: Spend most of the time executing instructions on the processor (cryptographic hashing, video processing, heavy calculations). These block Node's single-threaded event loop.
Q5How do Worker Threads solve the CPU-bound task bottleneck?
  • Concept: The worker_threads module allows running CPU-intensive JavaScript execution in separate OS threads.
  • Heap Structure: Each worker has its own isolated V8 engine instance and call stack, but they can share memory directly using SharedArrayBuffer (unlike child processes).
  • Communication: Workers communicate with the parent thread via message channels (MessagePort).

Unlock the remaining 52 Node.js (Medium) questions

You've completed the 5 free sample questions. Get unrestricted lifetime access to every question, model answer, implementation challenge, and all 27+ technologies for a single payment.

₹399 India / $9 International · One-time settlement · Zero subscription

CROSS-DIFFICULTY NAVIGATION

Continue Preparing Node.js

Node.js Interview Questions (Medium) | DevPrep | DevPrep