Back to the blog
A Gentle Note on Backpressure

A Gentle Note on Backpressure

A Gentle Note on Backpressure

When a fast producer meets a slow consumer, something has to give. The question is what — and backpressure is how a well-behaved system answers it.

Three honest options

  1. Buffer — absorb the spike, until memory says no.
  2. Drop — shed load deliberately, and admit it in your metrics.
  3. Slow down — push back on the producer so it eases off.

Each is a trade-off. The mistake is pretending you didn't make one.

async function* throttle<T>(src: AsyncIterable<T>, max: number) {
  let inFlight = 0
  for await (const item of src) {
    while (inFlight >= max) await tick()
    inFlight++
    yield item
  }
}

The systems I trust most are the ones that are honest about their limits.

Back to the blog
Pietro Piva VieiraPietro Piva Vieira

Built with care in the Frutiger Aero spirit — bright skies, glossy glass, and a little nostalgia.

© 2026 Pietro Piva Vieira · All rights reserved.