---
title: "Discussion on \"Day 3: Streams & Backpressure — Scalable File/Data Pipelines\" | Hashnode"
description: "Discussion on \"Day 3: Streams & Backpressure — Scalable File/Data Pipelines\". Ever tried copying a huge file in Node.js with fs.readFile or fs.writeFile?Yeah… your memory usage probably spiked like crazy. That’s because those methods load the entire file into memory before doing anything.\nThat’s fine for small files. But when ..."
url: "https://hashnode.com/posts/day-3-streams-and-backpressure-scalable-filedata-pipelines/68b831c886753bb184e957d9"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Day 3: Streams & Backpressure — Scalable File/Data Pipelines](https://day-1-deep-dive-into-nodejs-event-loop.hashnode.dev/day-3-streams-and-backpressure-scalable-filedata-pipelines?utm_source=hashnode&utm_medium=feed)

Ever tried copying a huge file in Node.js with fs.readFile or fs.writeFile?Yeah… your memory usage probably spiked like crazy. That’s because those methods load the entire file into memory before doing anything. That’s fine for small files. But when ...

Sep 3, 2025 · 4 min read · day-1-deep-dive-into-nodejs-event-loop.hashnode.dev  
Updated Sep 4, 2025  
Read the article

-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#streams](https://hashnode.com/tag/streams)
-   [#backpressure](https://hashnode.com/tag/backpressure)
-   [#writable-streams](https://hashnode.com/tag/writable-streams)
-   [#readable-streams](https://hashnode.com/tag/readable-streams)
-   [#flow-control](https://hashnode.com/tag/flow-control)
-   [#event-driven-programming](https://hashnode.com/tag/event-driven-programming)
-   [#datapipelines](https://hashnode.com/tag/datapipelines)
-   [#scalability](https://hashnode.com/tag/scalability)

## Written by

[Aaditya Shreeram](https://hashnode.com/@aadityashreeram)

@aadityashreeram · Chennai

  
[View profile](https://hashnode.com/@aadityashreeram)

One day at a time

## Responses 1

Markdown supported · ⌘↵ to post

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[4d ago](https://hashnode.com/posts/day-3-streams-and-backpressure-scalable-filedata-pipelines/68b831c886753bb184e957d9/comment/6af2107f031f8bf7cab7aaa2)

Treat backpressure as a contract between producer and consumer, not a nice-to-have. Prefer pipe or pipeline so pause/resume and destroy propagate; if you wire data and drain by hand, always honor the boolean from write and wait for drain before the next chunk. Bound highWaterMark for objectMode streams so a slow sink cannot balloon RSS. Destroy both ends on error, clear listeners, and avoid buffering an entire file before any write — that pattern is what turns a large upload into a leak under load.

Ops prove-out on a canary: stream a multi-gigabyte payload through the pipeline while watching RSS and event-loop lag. RSS should plateau near the configured buffer budget, not climb with file size. Throttle the consumer artificially and confirm the producer pauses; remove the throttle and confirm drain resumes without duplicate chunks. Abort mid-stream and verify both sockets and file descriptors close with no leftover listeners on the next request.
