Backpressure is a flow-control mechanism in which a component that cannot keep up signals its upstream producers to send less data or to wait. Instead of buffering without limit until memory runs out, the system propagates the overload backwards, so producers slow down, pause or deliberately reject work in a controlled way.
What is backpressure?
Every system has stages that produce work and stages that consume it. When producers are faster than consumers for longer than buffers can absorb, something has to give. Backpressure is the answer that keeps the system stable: the slow stage pushes back against the fast stage and tells it to slow down. The term comes from fluid dynamics, where resistance in a pipe pushes back against the flow.
Without backpressure, the overload does not disappear, it only moves. Queues grow, memory fills up, latency rises for every request in the queue and in the end a process is killed or a broker runs out of disk. With backpressure, the overload becomes visible at the edge of the system, where it can be handled deliberately.
How backpressure works
There are three basic strategies when a consumer cannot keep up:
- Slow down the producer: the producer blocks or waits until the consumer has capacity. This is true backpressure.
- Buffer: queue the work temporarily. Buffers absorb short bursts but must be bounded, otherwise they only delay the failure.
- Drop or reject: discard work or return an error, so the caller can retry later. This is often called load shedding.
Robust systems combine all three: a bounded buffer for bursts, a signal to producers when the buffer fills up and a clear rejection when that is not enough.
Backpressure in practice
- TCP: the receive window tells the sender how much data the receiver can accept. A slow reader automatically slows down the sender.
- Reactive Streams: the specification behind libraries such as Project Reactor and RxJava, and adopted in Java 9 as
java.util.concurrent.Flow, lets a subscriber request a specific number of elements withrequest(n). The publisher never sends more than requested. - HTTP APIs: a server under load responds with
429 Too Many Requestsor503 Service Unavailable, optionally with aRetry-Afterheader, which is backpressure combined with rate limiting. - Message brokers: with Kafka, consumers pull at their own pace, so overload shows up as growing consumer lag instead of crashed consumers. Push-based systems need explicit limits such as prefetch counts.
- Telemetry pipelines: the OpenTelemetry Collector's
memory_limiterprocessor refuses incoming data when memory use crosses a limit, and OTLP clients are expected to retry with backoff.
Common anti-patterns
- Unbounded queues in thread pools or in-memory channels, which turn every overload into an out-of-memory error.
- Retrying immediately on rejection, which multiplies the load instead of reducing it and can trigger a thundering herd.
- Timeouts that are longer upstream than downstream in the wrong direction, so callers keep waiting for work that has already been abandoned.
- Silent dropping without a metric, which hides data loss until someone notices missing records.
How to monitor backpressure
Backpressure is visible in a few signals, ideally collected for every stage of a pipeline:
- Queue depth and consumer lag, and above all their trend: a steady rise means consumers are permanently slower than producers.
- Time spent waiting in the queue, separate from processing time.
- Rejected, throttled and dropped items, for example HTTP 429 and 503 rates or the refused-data metrics of the OpenTelemetry Collector.
- Utilization of the consumers, to decide between scaling out and fixing a slow dependency.
Alert on sustained growth rather than on a single high value, because short bursts are exactly what buffers are for.
It also helps to know where the system sheds load when backpressure is not enough. Every stage should have an explicit policy: block, drop the oldest item, drop the newest item or reject with an error. Document that policy and expose a counter for each outcome. During an incident, these counters answer the most important question quickly: is data being delayed or is it being lost? Messages that cannot be processed at all belong in a dead letter queue instead of blocking the main queue. Finally, test overload deliberately in load tests, because backpressure paths are rarely exercised in normal operation and often fail in surprising ways.
How Obseria helps
Queue monitoring in Obseria tracks lag, depth and throughput for Kafka and other brokers and links them to the consumer services in TopoGraph. The Obseria Pipeline itself uses bounded buffers and reports refused and dropped telemetry, so overload in your observability data is visible too.