Skip to content

Shared memory

A queue with a ceiling

Producers, consumers, and the moment a full queue makes somebody wait.

10 minutes · bounded buffer · blocking send · backpressure

Backpressure is just a small queue

An unbounded queue never makes anybody wait, which sounds like a feature until the producer is faster than the consumer and the queue is the thing that runs the machine out of memory. A bounded queue moves the waiting to the producer, where it belongs.

This is the same idea as the concurrency limit in the async track, seen from the other side. There, a semaphore stopped four jobs from starting at once. Here, a full buffer stops a producer from running ahead. Both are backpressure, and both work by making somebody wait somewhere visible.

Everything you do here stays in this browser.