🟢 Node.js Intermediate

What is backpressure in Node.js streams?

Why Interviewers Ask This

This question targets practical, hands-on experience with Node.js. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.

Answer

Backpressure is a mechanism in Node.js streams to prevent a fast readable source from overwhelming a slow writable destination. Without backpressure, data would pile up in memory until the process crashes with an out-of-memory error. The writable stream's write(chunk) method returns false when its internal buffer is full (exceeding the highWaterMark, default 16KB). The readable stream should pause (readable.pause()) at this signal and wait for the writable to emit the "drain" event before resuming. The pipe() method handles this automatically — it pauses the readable when the writable signals backpressure and resumes when it drains, making it the recommended approach for connecting streams. Manual backpressure management is needed when building custom Transform streams or implementing your own pipeline logic. Ignoring backpressure causes memory leaks in data-intensive applications like ETL pipelines and file processors.

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Node.js candidates.