10. System design building blocksBackpressure
Backpressure
Backpressure is a way for a slow part of a system to make the faster parts upstream slow down, so work doesn’t pile up faster than it can be done. Without it, the gap between what arrives and what gets processed collects in queues, and an unbounded queue hides the problem as ever-growing delay until the machine runs out of memory. With it, queues have a fixed size, and when one fills, the producer is made to wait, told to retry later, or has its extra work dropped on purpose, which is called load shedding. TCP’s flow control is a familiar example, as are streaming libraries that only pull the next item when the consumer is ready. The aim is to fail early and visibly rather than slowly and everywhere.
In this lesson: A pipe-flow sim where a slow consumer overflows the queue, then load shedding kicks in.