← Back to Node.js performance map
🌊
Node.js Performance

Streaming Responses

Stream large responses instead of building huge payloads in memory.

streams

Detailed Description

Streaming sends data in chunks instead of building the full response in memory. This reduces memory pressure and lets clients start receiving data earlier.

Use streams for exports, large query results, file downloads, server-sent events, and long-running responses. Respect backpressure so producers do not overwhelm consumers.

Mental Model

read chunks
-> res.write
-> backpressure
-> res.end

When To Use

  • ->Large exports
  • ->Long-running responses
  • ->Avoid buffering huge arrays before sending
Tools: Node streams, pipeline, server-sent events, CSV export
stream-response.js

Live Editor

Loading...

Output

Run code to see output...