Skip to main content
Lexicon
Lexicon

Backpressure (Flow Control)

Difficulty: Advanced
3 min read

In plain English

Plain definition

Backpressure is how a slower system tells a faster one to ease off, so data doesn't pile up faster than it can be processed. Without it, queues grow unbounded until memory runs out or the whole system crashes.

Backpressure is fundamentally a control-theoretic problem: without it, any system where production rate can exceed consumption rate degrades into unbounded memory growth, GC thrash, or OOM kills. It manifests differently depending on the transport layer. At the TCP layer, the sliding window mechanism is backpressure — a receiver advertises a shrinking window as its socket buffer fills, and the sender’s kernel throttles writes accordingly. HTTP/2 and gRPC generalize this per-stream via WINDOW_UPDATE frames, enabling multiplexed streams to backpressure independently over a shared connection, which is why HOL-blocking-adjacent stream stalls in gRPC are usually a flow-control credit exhaustion issue, not a transport-level block.

At the application layer, backpressure strategies fall into a few canonical patterns:

  • Credit-based flow control: the consumer grants explicit demand units (e.g., Reactive Streams’ request(n), RSocket), and the producer is contractually forbidden from emitting more than the outstanding credit. This is a pull-based model that eliminates unbounded buffering by construction, without blocking the producer.
  • Bounded queue + block/reject: producers write to a fixed-capacity queue; once full, the producer either blocks (synchronous backpressure, risking upstream cascading stalls) or rejects with a fast-fail (e.g., RejectedExecutionException, load shedding).
  • Rate signaling via out-of-band metrics: consumers expose lag or queue-depth metrics (e.g., Kafka consumer group lag) that an external controller or the producer itself polls to throttle — this is push-based and inherently lossy/delayed, since the signal is not synchronous with the data path.

The critical architectural failure mode is backpressure leakage across abstraction boundaries: a system may correctly implement flow control at one hop (e.g., a reactive stream inside a service) but silently convert it into unbounded buffering at the next hop (e.g., an unbounded in-memory queue feeding a downstream HTTP client with no timeout). This is how a single slow consumer several hops downstream propagates into an OOM at the ingress tier — colloquially a ‘backpressure void.’ Distinguishing genuine backpressure from a Gray Failure is subtle: a consumer applying legitimate backpressure looks identical, from a latency-percentile view, to a partially failed consumer, which is why naive circuit breakers tuned on latency alone can trip incorrectly under healthy backpressure conditions.

In distributed pipelines (Kafka, Flink, Pulsar), backpressure is often deliberately asymmetric: the broker acts as a durable buffer that decouples producer and consumer rates entirely, converting a flow-control problem into a storage-capacity and consumer-lag problem instead. This trades immediate backpressure propagation for elasticity, but reintroduces the original problem at a longer time constant — unbounded topic retention growth is backpressure deferred, not solved. Systems that need true end-to-end backpressure across such a broker must build flow-control signaling on top of the broker’s pull-based consumption model (for example, producers throttling on consumer lag), since the broker itself provides no synchronous backpressure to the original producer. Flink’s credit-based network stack propagates backpressure only between operators inside a job; at a Kafka source it simply reads more slowly.

About this page

Credited to

Dates

Published

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

More from KBY that goes with this term.