What is non-blocking I/O?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Node.js development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
Non-blocking I/O means that when Node.js initiates an I/O operation (reading a file, making a network request, querying a database), it does not wait for that operation to complete before moving on to execute other code. Instead, it registers a callback function and continues processing other tasks. When the I/O operation completes, the event loop picks up the callback and executes it. Blocking I/O (the traditional approach) would halt program execution until the operation finishes, wasting CPU cycles while waiting. Node.js's non-blocking model means a single thread can serve thousands of concurrent requests — while one request is waiting for a database query, the thread handles other requests. This makes Node.js extremely efficient for I/O-bound workloads. However, CPU-intensive tasks (image processing, heavy computation) still block the event loop since they don't involve I/O waits.
Pro Tip
This topic has Node.js-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.