Backpressure

Learn the concept of backpressure in distributed systems and how applications exert backpressure.

Backpressure is a very useful concept in the field of distributed systems. It is essentially a resistance to the desired flow of data through a system. This resistance can manifest in different ways, such as increased latency of requests or failed requests.

Backpressure can also be implicit or explicit.

Implicit backpressure

Implicit backpressure arises in a system that is overloaded by a traffic surge and becomes extremely slow.

Explicit backpressure

A system that rejects some requests during a traffic surge to maintain a good quality service essentially exerts explicit backpressure to its clients.

Note: Most of the techniques used to contain failure reflect how applications exert backpressure and how their clients handle backpressure.

Let’s learn how applications can exert backpressure.

Techniques used by applications to exert backpressure

It is useful for a system to know its limits and exert backpressure when they are reached instead of relying on implicit backpressure. Otherwise, there can be many unexpected failure modes, which are harder to deal with when they happen.

Load shedding

The main technique to exert backpressure is load shedding. An application is aware of the maximum load it can handle and rejects any requests that cross this threshold to keep operating at the desired levels.

Selective client throttling

A more specialized form of load shedding is selective client throttling, where an application assigns different quotas to each of its clients.

This technique can also be used to prioritize traffic from some more important clients.

Let’s consider a service responsible for serving the prices of products, which is used both by systems responsible for displaying product pages and systems responsible for receiving purchases and charging the customer. In case of a failure, that service could throttle the former type of system more than the latter since purchases are considered more important for a business. They also tend to constitute a smaller percentage of the overall traffic.

Note: In the case of asynchronous systems that use message queues, load shedding can be performed by imposing an upper bound on the size of the queue. There is a common misconception that message queues can help absorb any form of backpressure without any consequences. However, this comes at the cost of an increased backlog of messages, leading to increased processing latency or even failure of the messaging system in extreme cases.

Get hands-on with 1400+ tech skills courses.