streams-backpressureAnswer last reviewed July 2026

What is highWaterMark actually controlling? And when you flip on objectMode, what changes about how it counts?

A strong answer knows highWaterMark is a soft threshold whose units change by mode, and can do the objectMode memory math the count-based default hides

What an AI-prepared candidate might say

highWaterMark is basically the buffering threshold for a stream. On a writable, once the buffered data reaches it, write() starts returning false and the producer is supposed to wait for 'drain'. On a readable it's how much the stream pre-reads into its internal buffer before it pauses the underlying source. The default is 64KiB for byte streams, I believe. And it's a soft threshold, you can keep writing past it and the stream just keeps buffering. With objectMode: true the units change from bytes to objects, and the default becomes 16, so sixteen objects buffered no matter how big each one is. That's the classic gotcha, sixteen large objects can be a ton of memory even though sixteen sounds small. Tuning it is a memory versus throughput thing, bigger buffers mean fewer pauses and larger reads, smaller ones keep memory tight.

Senior
Locked

How the soft threshold really behaves on both sides, writable signaling versus readable read-ahead, and why a Transform is carrying two allowances at once.

Unlock the depth
Staff
Locked

Capacity planning for objectMode when your objects weigh megabytes, how allowances multiply across stages and concurrency, and the fs read-size lever.

Unlock the depth
Follow-up chain
What is highWaterMark actually controlling? And when you flip on objectMode, what changes about how it counts? | NodeBook