Backpressure
A flow-control mechanism where an overloaded downstream consumer signals upstream producers to slow down, drop, or buffer work so queues do not exhaust memory and trigger cascading crashes
Table of Contents
Structure Diagram
What is Backpressure?
A flow-control mechanism where an overloaded downstream consumer signals upstream producers to slow down, drop, or buffer work so queues do not exhaust memory and trigger cascading crashes. It is a core concept in Traffic & Scaling within Cloud / DevOps.
Core Principles
Borrowed from fluid dynamics, Backpressure is a distributed systems flow-control mechanism triggered when an upstream producer emits work faster than a downstream consumer can process it. Without backpressure, unbounded queues grow until latency explodes and processes crash with Out-of-Memory (OOM) errors.
With backpressure, consumers explicitly signal their available capacity upstream, forcing producers to slow down, pause, or shed excess load so the system degrades gracefully instead of collapsing.
Practical Takeaways
- Never use unbounded queues: Always cap in-memory buffers and thread-pool queues. When a bounded queue fills up, fail fast with
503 Service Unavailableor429rather than queuing stale requests indefinitely. - Favor pull-based consumption: Pull models (like Kafka consumers or Reactive Streams
request(n)) naturally let downstream workers pull only as much work as they can handle. - Combine with priority load shedding: Under extreme overload, drop low-priority background or analytics traffic early to preserve latency for critical user transactions.
Notable Examples
- TCP Sliding Window & HTTP/2 Flow Control: Classic protocol-level backpressure where receivers advertise available buffer space to senders.
- Apache Kafka & Amazon SQS: Decouples bursty producers from slower consumers using durable broker logs pulled at the consumer's own pace.
- Node.js Streams & Project Reactor: Propagates
highWaterMarkand demand signals across async processing pipelines.