Guided Notes

Streams & Buffers

Processing data piece by piece — Buffers, readable/writable/transform streams, pipeline, backpressure, and when streams beat reading whole files.

Why streams

Slide 1 / 5

readFile loads an entire file into memory. For a 4 GB log file or a video upload, that's slow and may crash the process.

Streams process data in chunks as it arrives: • lower memory use (constant, not proportional to file size), • faster time to first result, • composable: read → transform → write.

HTTP requests and responses, files, compression (zlib) and child process I/O are all streams.