.NET Architecture & System Design Interview Question #24

What is backpressure?

Architecture Fundamentals, Scalability, Availability & Performance Junior Beginner

Quick Interview Answer

Backpressure is a mechanism for preventing producers from overwhelming consumers when work arrives faster than it can be processed. Instead of accepting unlimited work, the system slows, buffers within limits, rejects, or signals producers to reduce the rate.

Detailed Explanation

Backpressure is a mechanism for preventing producers from overwhelming consumers when work arrives faster than it can be processed. Instead of accepting unlimited work, the system slows, buffers within limits, rejects, or signals producers to reduce the rate.

Backpressure protects memory and downstream dependencies. Queues should have bounded capacity or operational policies because an unlimited queue can simply move the overload problem into storage and increase latency.

Code Example

Producer ---> [bounded queue] ---> Consumer
                  |
               capacity reached
                  |
        slow/reject/throttle producer