backpressure
A slow consumer signalling a fast producer to pause, so data does not pile up in memory faster than it can be handled.
In more detail
Without it the unprocessed data grows until the process slows down or runs out of memory. Most streaming and messaging systems provide some form of it.
Example
In Node.js, write() returning false and the drain event are the backpressure signals; pipe() and pipeline() handle them for you.Related terms
- streaming — Sending a response in pieces as they become available instead of building the whole thing first.
- message queue — A store that holds messages from producers until consumers are ready to process them, decoupling the rate of arrival from the rate of work.
- WebSocket — A protocol that turns an HTTP connection into a long-lived, two-way channel where client and server can each send messages at any time.
- memory — The fast, temporary working space where running programs keep their data; it is emptied when the machine powers off.
- bounded queue — A waiting line for tasks with a maximum size, so that when it is full new work is rejected instead of piling up in memory.
- timeout — A limit on how long a caller waits for an answer before giving up.
- highWaterMark — A stream option giving how much data its internal buffer should hold before it signals backpressure: bytes normally, or objects in object mode.
- drain event — The event a Writable stream emits when its buffer has emptied after write() returned false, meaning it is safe to write again.
- stream.pipeline() — A Node.js function that connects streams in a chain, handles backpressure, and destroys every stream in the chain if any of them fails.
- load shedding — Deliberately rejecting some requests when overloaded so the requests that are accepted can still be served well.
- admission control — Deciding at the entrance whether a request may start, based on how much work the system can still take.
Taught in
- WebSockets — Modern API Architecture: REST, GraphQL & gRPC
- The ExecutorService — Modern Java: Virtual Threads & High-Throughput Services
- Native Compression: node:zlib & Streaming Codecs — Node.js Internals & Backend Services
- Stream Mechanics: Readable Streams & Flowing Modes — 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
- Transform Streams: Custom Packet Decoding & Codecs — Node.js Internals & Backend Services
- Stream Pipelines: pipeline, AbortSignal & Teardown — Node.js Internals & Backend Services
- Thread Pooling: Piscina & CPU-Bound Workload Pools — Node.js Internals & Backend Services
- Backpressure And Load Shedding — Scalable System Design & Distributed Architecture
- Worked Design One: Scaling The Ticket Booking System — Scalable System Design & Distributed Architecture
- Worked Design Three: Scaling The Metrics Pipeline — Scalable System Design & Distributed Architecture