Vaibhav Jain
← All notes
working ·

Backpressure

How systems signal upstream producers to slow down when consumers cannot keep up.

#systems#queues

Backpressure is how a system tells upstream producers to slow down.

When a producer is faster than a consumer, work starts accumulating somewhere. Usually that “somewhere” is a queue or buffer. If nothing pushes back, the queue can grow until the system becomes slow, unstable, or crashes.

The core idea

A system under pressure can usually do one of four things:

  1. buffer the work,
  2. drop some work,
  3. fail fast,
  4. or slow the producer.

Backpressure is option four.

Simple picture

Producer ---> Queue ---> Consumer
    ^                      |
    |                      |
    +------ slow down -----+

The important part is the feedback signal. The consumer, queue, or runtime needs a way to communicate upstream that the current rate is too high.

Where this shows up

  • streams
  • network protocols
  • message queues
  • async runtimes
  • databases under write load
  • APIs with rate limits