highWaterMark
A stream option giving how much data its internal buffer should hold before it signals backpressure: bytes normally, or objects in object mode.
In more detail
The default is 64 KiB for byte streams in current Node.js and 16 objects in object mode. It is a threshold, not a hard limit: writes beyond it are still buffered, but write() returns false.
Related terms
- backpressure — A slow consumer signalling a fast producer to pause, so data does not pile up in memory faster than it can be handled.
- Writable stream — A Node.js stream you write data to, such as a file being written, an HTTP response or a socket.
- object mode — A stream setting that lets chunks be any JavaScript value, such as parsed records, instead of only strings and Buffers.
Taught in
- Native Compression: node:zlib & Streaming Codecs — Node.js Internals & Backend Services
- Writable Streams: Drain Events & highWaterMark — Node.js Internals & Backend Services
- Backpressure Engineering: Handling Mismatched I/O — Node.js Internals & Backend Services