Loading...

12-Hour Money-Back Guarantee

📘 Why Queues Are Not Backpressure

📘 Why Queues Are Not Backpressure

📘 Why Queues Are Not Backpressure

3 Apr 20222 min read

Buffers hide overload. They don’t fix it.

“We added a queue, so we’re safe now.”
— Famous last words before an outage.

1️⃣ The Dangerous Misconception

Common belief ❌

“If traffic spikes, just put a queue in front.”

Reality ✅

A queue absorbs load, but does not reduce it.

It only delays the pain.

2️⃣ What Backpressure Actually Means

Backpressure means slowing or stopping upstream producers when downstream is overloaded.

A queue does none of that by default.

3️⃣ The Core Failure Mode

When arrival rate > processing rate:

λ (incoming) > μ (processing)

Queue length grows without bound.

The queue becomes a memory leak with latency.

4️⃣ Why Queues Make Tail Latency Worse

What happens over time:

  1. Requests wait longer

  2. Timeouts trigger

  3. Clients retry

  4. Load multiplies

  5. System collapses

Queues convert overload into retry storms.

5️⃣ Code Example — Fake Safety ❌

const queue = [];

app.post("/work", (req, res) => {
  queue.push(req.body);
  res.send("Accepted");
});

Why This Is Dangerous

  • No bound

  • No rejection

  • No feedback to clients

6️⃣ Bounded Queues ≠ Backpressure (Still Not Enough)

if (queue.length > 10_000) {
  throw new Error("Queue Full");
}

Better, but still:

  • Clients already sent traffic

  • Latency still spikes

  • Retries still happen

7️⃣ What Real Backpressure Looks Like

✅ Upstream Throttling

let inFlight = 0;
const MAX = 100;

app.get("/data", async (req, res) => {
  if (inFlight >= MAX) {
    return res.status(429).send("Too Busy");
  }

  inFlight++;
  try {
    res.send(await process());
  } finally {
    inFlight--;
  }
});

Work is rejected early, not queued forever.

8️⃣ When Queues Are Actually Useful

Queues are not evil — just misunderstood.

Queues are good for:

✔ Async work
✔ Decoupling systems
✔ Load smoothing
✔ Event processing

Queues are bad for:

❌ User-facing latency paths
❌ Unlimited buffering
❌ Failure containment

9️⃣ The Hidden Cost of Queues

Cost Impact
Memory growth OOM
Latency Unbounded
Retries Amplified
Visibility Poor
Fairness Broken

1️⃣0️⃣ Real-World Examples

Kafka

  • Backpressure via consumer lag

  • Producers must slow down

TCP

  • Window size

  • Sender adapts rate

HTTP

  • 429 / 503

  • Retry-After

The queue alone is never the control loop.