Systems and Networking · 16 min · free with an account

Backpressure

Lesson preview · about 30%

A queue with no limit is a crash with a delay.

Core idea

Every queue needs a bound and a policy for what happens at that bound.

Start with the idea

When a producer is faster than a consumer, an unbounded channel converts a throughput problem into a memory problem and then an OOM. Backpressure means the queue has a bound and the producer waits, sheds load, or fails fast when it is full. A bounded async send may await capacity; a synchronous bounded send may block, while a nonblocking send can fail immediately.

Backpressure keeps a fast producer from accumulating unlimited unfinished work. A bounded queue sets a maximum number of pending items; when full, the producer can wait, reject, drop according to a policy, or reduce its input rate. Those choices change user-visible behavior. Waiting can propagate pressure upstream; rejecting with a clear retry signal can protect latency for requests already accepted; dropping may be valid for telemetry but unacceptable for payments. The bound should reflect memory budget and acceptable queue delay, not an arbitrary round number.

Keep learning, for free

The rest of this lesson is waiting for you.

Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.

No payment details. Your account opens the complete Academy.

← All lessons in Rust Interview Prep