Loading...
āœ“

12-Hour Money-Back Guarantee

šŸ“˜ Why Async ≠ Scalable

šŸ“˜ Why Async ≠ Scalable

šŸ“˜ Why Async ≠ Scalable

3 Apr 20223 min read

Non-blocking code can still melt your system

Async removes waiting.
Scalability removes limits.
They are not the same thing.

1ļøāƒ£ The Popular Myth

ā€œWe made everything async — now it scales.ā€

Async helps a single thread do more work.
Scalability is about how much total work the system can safely handle.

You can have:

  • Fully async code

  • Zero locks

  • No blocking
    …and still go down under load.

2ļøāƒ£ What Async Actually Solves

Async helps when:

  • Threads are waiting on I/O

  • Latency is dominated by network

  • Concurrency is moderate

Async does NOT:

  • Increase CPU

  • Increase DB capacity

  • Remove hot keys

  • Fix amplification

Failure Mode #1 — Async Fanout Explosion

āŒ Naive Async Code

async function getFeed() {
  const posts = await db.getPosts();

  return Promise.all(
    posts.map(p => fetchComments(p.id)) // async ≠ cheap
  );
}

What Happens

  • 1 request → N async calls

  • N sockets

  • N callbacks

  • N failure chances

Async just made amplification faster.

Failure Mode #2 — Async Still Queues (Hidden)

Async systems still queue — just not where you expect.

Where queues exist:

  • Event loop

  • Thread pool

  • Connection pool

  • OS scheduler

āŒ Async without limits

app.get("/data", async (req, res) => {
  res.send(await db.fetch());
});

If traffic > DB capacity:

  • Promises pile up

  • Memory spikes

  • Latency explodes

Failure Mode #3 — Async Amplifies Tail Latency

Async increases concurrency, which:

  • Increases contention

  • Increases variance

  • Increases P99

Async improves P50 and worsens P99 unless controlled.

Failure Mode #4 — Async Makes Failure Faster

āŒ Fast Failure Propagation

Promise.all([
  serviceA(),
  serviceB(),
  serviceC()
]);

One slow service → whole request waits
One failing service → retries explode

Async accelerates cascading failures.

→ What Actually Makes Systems Scalable

Scalability requires explicit limits

Requirement Needed
CPU safety Concurrency caps
DB safety Connection limits
Latency Timeouts
Stability Backpressure
Survival Load shedding

Async alone gives none of these.

Async + Limits = Scalable

āœ… Correct Pattern

import pLimit from "p-limit";

const limit = pLimit(100);

app.get("/data", async (req, res) => {
  try {
    const result = await limit(() => fetchWithTimeout(200));
    res.send(result);
  } catch {
    res.status(503).send("Busy");
  }
});

This adds:

  • Concurrency control

  • Timeouts

  • Load shedding

Now it scales.

Async vs Scalable (Clear Comparison)

Property Async Scalable
Non-blocking āœ… Optional
Concurrency High Controlled
Backpressure āŒ āœ…
Load shedding āŒ āœ…
P99 safety āŒ āœ