Backpressure

역압

Signal producers to slow down when consumers cannot keep up.

···
html
<div class="v"><header><b>BACKPRESSURE</b><span id="state"></span></header><main><div class="meter"><div class="fill" id="fill"></div></div><div class="rates" id="rates"></div></main><footer>demand controls the source</footer></div>
css
.v{width:min(92vw,660px);height:min(86vh,310px);box-sizing:border-box;padding:clamp(9px,2.5vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);display:flex;flex-direction:column;gap:7px;color:var(--fg);font:500 clamp(15px,3.2vmin,17px)/1.25 var(--font-sans, sans-serif)}.v header,.v footer{display:flex;justify-content:space-between;align-items:center;gap:8px;white-space:nowrap}.v header b{color:var(--accent);font-size:.9em}.v header span,.v footer{color:var(--muted);font-size:.82em}.v main{flex:1;min-height:0;position:relative;overflow:hidden}.v .mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.v .active{background:var(--accent)!important;color:var(--bg)!important;border-color:var(--accent)!important}.v .muted{opacity:.28} .meter{height:42%;margin-top:12px;border:1px solid var(--line);border-radius:7px;overflow:hidden}.fill{height:100%;background:var(--accent);transition:width .35s}.rates{height:38%;display:flex;align-items:center;justify-content:space-around;color:var(--accent);font:600 .85em ui-monospace,monospace}
js
let n=0;const fill=[20,48,80,95,66,35];function draw(){document.getElementById("fill").style.width=fill[n]+"%";document.getElementById("rates").textContent=n>=3?"producer  ↓  |  consumer →":"producer →  |  consumer →";document.getElementById("state").textContent=n>=3?"slow producer":"buffer filling";n=(n+1)%fill.length}draw();setInterval(draw,850)

Backpressure keeps a producer from endlessly filling a buffer when the consumer is slower. The consumer requests only what it can handle, or the producer pauses until writes complete.

A larger buffer handles short bursts but cannot solve a sustained rate mismatch. The demo shows production slowing as the buffer fills.

When to use

Use it to control memory and latency in streams, queues, and upload pipelines.

Open as page ↗