What 256 Cores Means for Node Apps
Last month the biggest server chip you can buy reached 256 cores, and your Node app, left to its defaults, uses one of them.
A server chip works like an office building full of desks. Each desk is a core - a worker inside the chip that can run one stream of instructions at a time. Your app sits at one desk, and the rest of the building stays dark while you pay rent on every floor.
It doesn’t look like a problem at first, because the monitoring graph says the machine is barely working. So nobody buys a smaller server, and nobody asks why customers are waiting. When traffic picks up, requests line up behind the one busy worker and pages get slow, even though the dashboard swears you have room to spare.
Node already ships everything you need to put the other desks to work, and most of it fits in a few dozen lines of code. The harder part is knowing how many desks you really have, and noticing the hallway everyone shares to fetch their files.
One Barista, Many Counters
Node runs your JavaScript on one thread, a single line of work that only one core can run at a time. Think of a coffee shop with a single, very fast barista. When an order needs the espresso machine (a database query, a file read, a call to another service), she starts it and takes the next order while it brews. Node’s event loop works the same way, and it’s why one Node process can juggle thousands of connections.
The trick falls apart when an order needs her hands the whole time. Parsing a giant blob of data from an API, resizing an image, hashing a password or rendering a big template all hold her at the counter, and everyone behind that customer waits. Building more counters doesn’t help unless you also hire more baristas, and on a 256-core chip you have room for a lot of them.
You can watch the shop sit empty. Every example in this post is TypeScript that current Node LTS releases run directly - Node strips out the types and runs what’s left, with no build step and no type checking. The .mts extension tells Node each file is an ES module, the same job .mjs does for plain JavaScript, so the examples work no matter what your package.json says.
This first one pins one Node thread at 100% for five seconds and then reports how busy the whole machine looked:
// busy.mts - max out one thread, then measure the whole machine
import os from 'node:os';
type Times = os.CpuInfo['times'];
const before: Times[] = os.cpus().map((c) => c.times);
const end = Date.now() + 5000;
while (Date.now() < end) {} // pure JavaScript, no I/O: the event loop is stuck here
const after: Times[] = os.cpus().map((c) => c.times);
let busy = 0;
let total = 0;
after.forEach((t, i) => {
const b = before[i];
const keys = Object.keys(t) as (keyof Times)[];
const all = keys.reduce((sum, k) => sum + (t[k] - b[k]), 0);
busy += all - (t.idle - b.idle);
total += all;
});
console.log(`machine-wide CPU while one Node thread was maxed: ${((busy / total) * 100).toFixed(1)}%`);
console.log(`one core out of ${os.cpus().length} would be ${(100 / os.cpus().length).toFixed(1)}%`);
The two numbers come out nearly the same. On an 8-CPU machine that’s 12.5%, which means a CPU graph sitting around 12% can describe a process that is completely out of breath. On an EPYC 9996 with all 512 threads visible, one maxed-out Node thread shows up as about 0.2%.
Server Chips Went Wide
This year three of the biggest names in chips went wide. Sixth-generation EPYC chips from AMD went on general sale November 10, and the top part, the EPYC 9996, has 256 cores and 512 threads in a single socket. In March, Nvidia launched an 88-core Arm-based CPU called Vera and pitched it squarely at AI agents and reinforcement learning. A week later Arm started selling a chip under its own name for the first time - the AGI CPU, with up to 136 cores and a dedicated core for every program thread.
AI agents don’t spend most of their time on the GPU - they call tools, run code in sandboxes, shuffle data and wait on the network, which pushes work back onto the CPU as thousands of small, concurrent jobs. Low-level chip design shifts like this one are built for workloads that look a lot like an ordinary web backend: many small requests, lots of waiting, a little bit of computation in between.

Count What You Actually Have
Before you spread work out, find out how many CPUs your process is allowed to use. Getting this number wrong in either direction costs you: too few workers wastes the machine, and too many means they fight each other for the same cores.
// cores.mts
import os from 'node:os';
console.log('logical CPUs on the host:', os.cpus().length);
console.log('CPUs this process may use:', os.availableParallelism());
os.availableParallelism() is the one to trust. It asks the operating system which CPUs this process may run on, and on Linux it also reads the container’s CPU limit. os.cpus().length is the wrong number for sizing workers because it counts every CPU on the host, including the ones your process isn’t allowed to use.
Keep in mind that it counts logical CPUs. On a chip with two hardware threads per core, the EPYC 9996 reports 512, but those two threads share one core’s execution units. For JavaScript that keeps the CPU busy, two workers on sibling threads won’t give you anywhere near double the throughput, so treat the physical core count as your starting point and measure from there.
Step 1: Run One Process per Core With cluster
The first goal is simple: one slow request should never make every other customer wait. The cluster module starts several copies of your server that share one port, so a stuck event loop only stalls its own share of the traffic.
// cluster-server.mts
import cluster from 'node:cluster';
import http from 'node:http';
import { availableParallelism } from 'node:os';
import process from 'node:process';
// Overrides let you run fewer workers than CPUs, or one cluster per NUMA node on its own port.
const workers = Number(process.env.WEB_WORKERS) || availableParallelism();
const port = Number(process.env.PORT) || 3000;
if (cluster.isPrimary) {
console.log(`primary ${process.pid} starting ${workers} workers`);
for (let i = 0; i < workers; i++) cluster.fork();
// A worker that crashes takes only its own requests down. Replace it.
cluster.on('exit', (worker, code, signal) => {
console.warn(`worker ${worker.process.pid} exited (${signal || code}), restarting`);
cluster.fork();
});
} else {
http
.createServer((req, res) => {
res.end(`handled by ${process.pid}\n`);
})
.listen(port);
}
Hit it a few times with curl localhost:3000 and the process ID changes from response to response. On every platform except Windows, the primary process accepts connections and hands them out in round-robin order. The docs explain why: letting the operating system pick a worker sounds better on paper, but in practice it piled over 70% of connections onto two of eight processes.
Now a request that hogs the CPU slows down one worker instead of the whole site, and a crash kills one worker instead of everything.
Separate processes come with a bill, because every worker has its own memory:
- Nothing in memory is shared. Sessions, rate-limit counters and in-process caches now exist once per worker. Keep sessions and logins in Redis or the database instead of in memory.
- Connection pools multiply. If each worker opens a pool of 10 database connections, 256 workers want 2,560 of them. PostgreSQL’s
max_connectionsdefaults to typically 100. Shrink the per-worker pool or put a connection pooler in front of the database before you scale out. - Memory adds up per worker. Each one carries its own JavaScript heap and its own copy of every module you load.
Step 2: Move Heavy Work Off the Event Loop With worker_threads
Clustering spreads requests across cores, but a single expensive request still freezes the worker that took it. Worker threads let a process hand that job to another thread and keep answering everyone else. The docs are blunt about the boundaries: workers are useful for CPU-intensive JavaScript and do not help much with I/O, because Node’s built-in async I/O is already more efficient than a thread could be.
Use a pool, because starting a new worker for every task usually costs more than it saves. Here’s a small one with no dependencies:
// pool.mts - a fixed-size pool of worker threads for CPU-heavy jobs
import { Worker } from 'node:worker_threads';
import { availableParallelism } from 'node:os';
type Job<In, Out> = {
data: In;
resolve: (result: Out) => void;
reject: (err: Error) => void;
};
export class WorkerPool<In, Out> {
file: URL;
idle: Worker[] = [];
queue: Job<In, Out>[] = [];
// Leave one CPU for the main thread's event loop.
constructor(file: URL, size = Math.max(1, availableParallelism() - 1)) {
this.file = file;
for (let i = 0; i < size; i++) this.idle.push(new Worker(file));
}
run(data: In): Promise<Out> {
return new Promise((resolve, reject) => {
this.queue.push({ data, resolve, reject });
this.next();
});
}
next(): void {
const worker = this.idle.pop();
if (!worker) return;
const job = this.queue.shift();
if (!job) {
this.idle.push(worker);
return;
}
const onMessage = (result: Out) => {
worker.off('error', onError);
this.idle.push(worker);
job.resolve(result);
this.next();
};
const onError = (err: Error) => {
// An uncaught exception kills the thread. Replace it so the pool keeps its size.
worker.off('message', onMessage);
this.idle.push(new Worker(this.file));
job.reject(err);
this.next();
};
worker.once('message', onMessage);
worker.once('error', onError);
worker.postMessage(job.data);
}
close() {
return Promise.all(this.idle.map((w) => w.terminate()));
}
}
The worker file holds the slow code:
// score-worker.mts - runs on its own thread, so a slow job can't block requests
import { parentPort } from 'node:worker_threads';
import { createHash } from 'node:crypto';
export type ScoreJob = { text: string; rounds: number };
parentPort?.on('message', ({ text, rounds }: ScoreJob) => {
// Stand-in for real CPU work: parsing, scoring, image resizing, templating...
let digest = text;
for (let i = 0; i < rounds; i++) {
digest = createHash('sha256').update(digest).digest('hex');
}
parentPort?.postMessage(digest);
});
And this proves the main thread stays free while the pool grinds:
// pool-demo.mts
import { WorkerPool } from './pool.mts';
import type { ScoreJob } from './score-worker.mts';
const pool = new WorkerPool<ScoreJob, string>(new URL('./score-worker.mts', import.meta.url));
const ticker = setInterval(() => console.log('event loop still ticking'), 250);
const started = performance.now();
const results = await Promise.all(
Array.from({ length: 8 }, (_, i) => pool.run({ text: `doc-${i}`, rounds: 300_000 })),
);
console.log(`${results.length} jobs in ${Math.round(performance.now() - started)} ms`);
clearInterval(ticker);
await pool.close();
The ticker keeps printing while the jobs run. Move the hashing loop onto the main thread and it goes silent until every job finishes, and your users feel that silence as a frozen page.
For production, a maintained pool library adds the things this one leaves out, like timeouts, cancellation and a cap on the queue. The shape stays the same: a fixed number of threads, a queue in front of them, and nothing slow on the main thread.
Step 3: Size the Thread Pool You Didn’t Know You Had
Even a single Node process has a few extra threads working behind the barista. Some jobs have no true asynchronous version at the operating system level, so Node hands them to a small back-room crew of helper threads and keeps taking orders while the crew works. Node sends these calls to that crew:
- every
fscall except the file watchers and the explicitly synchronous ones - async crypto such as
crypto.pbkdf2()andcrypto.scrypt() dns.lookup()- async
zlibcompression
The crew has four threads by default, whether the machine has 4 cores or 256. Everything on that list shares those four, so one slow kind of work can hold up all the others. Eight people logging in at the same moment can leave a tiny config file read waiting in line behind their password hashes.
You can watch it happen:
// threadpool.mts - show crypto hogging the shared pool and making file reads wait
import { pbkdf2 } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { promisify } from 'node:util';
const hash = promisify(pbkdf2);
const t0 = performance.now();
const ms = () => `${Math.round(performance.now() - t0)} ms`;
// Eight password hashes - think "eight people logging in at once".
const logins = Array.from({ length: 8 }, (_, i) =>
hash(`password-${i}`, 'salt', 600_000, 32, 'sha256'),
);
// A tiny, unrelated file read queued right behind them.
const config = readFile(new URL(import.meta.url)).then(() =>
console.log(`config file read finished at ${ms()}`),
);
await Promise.all([...logins, config]);
console.log(`all logins hashed at ${ms()}`);
Run it once with the default pool and once with a bigger one:
node threadpool.mts
UV_THREADPOOL_SIZE=16 node threadpool.mts
On a two-core test machine:
- Default pool of four: the config read waited about 300 ms, until a hash finished and freed up a thread.
- Pool of 16: the config read finished almost right away.
- Both runs: the eight hashes took the same total time, because two cores can only hash so fast.
A bigger pool keeps one slow kind of work from blocking everything else, but it can’t make CPU-heavy work finish faster than your cores allow. On a 256-core server, four helper threads leave nearly every core idle for hashing, compression and file work, so raising the number is the cheapest fix in this post.
Two rules for setting it:
- Set it before Node starts, in the environment or your process manager. Changing
process.env.UV_THREADPOOL_SIZEfrom inside your code isn’t guaranteed to work, because the pool may already exist by the time that line runs. - Don’t just max it out. The pool tops out at 1,024 threads, and Node starts every one of them the first time anything uses the pool. Start near the number of CPUs each process gets, then measure.
Memory Is the Hidden Bottleneck
Cores are only half the story. Every one of them needs data from memory, and memory has a fixed amount of bandwidth to share. I’ve been running into that limit since I was writing CPU-bound game clones on a machine with paltry RAM, and the new chips haven’t escaped it.
Divide the vendors’ own numbers by their core counts and you get a feel for it:
| Chip | Cores | Memory bandwidth | Per core (division) |
|---|---|---|---|
| AMD EPYC 9996 (standard DIMMs) | 256 | 1,024 GB/s per socket | about 4 GB/s |
| AMD EPYC 9996 (MRDIMMs) | 256 | 1,638 GB/s per socket | about 6.4 GB/s |
| Arm AGI CPU | 136 | 6 GB/s per core (stated) | 6 GB/s |
| Nvidia Vera | 88 | up to 1.2 TB/s | about 13.6 GB/s |
These are peak numbers and the last column is my own division, but the gap is too big to ignore - each core on Nvidia’s chip gets more than three times the memory bandwidth of a core on AMD’s flagship with standard memory. A lot of Node work is moving bytes rather than doing math - parsing JSON, copying buffers, and letting the garbage collector walk the heap. Pack 256 busy workers onto one socket and they can end up waiting in line for memory instead of for CPU, which looks exactly like “the CPUs are busy but nothing got faster.”
NUMA: Near Memory and Far Memory
On a big server, not all memory is equally close. The chip is split into regions, each with its own memory channels attached, and a core reading from its own region’s memory is faster than reaching across to another region (or across to the second socket). Engineers call this layout NUMA, for non-uniform memory access.
EPYC servers expose it as a BIOS setting called NUMA nodes per socket. On the previous EPYC generation, the factory default was one node per socket with memory spread across every channel, and four per socket was the recommendation for highly parallel workloads. Your hosting provider may have already picked one for you. Check what you got:
lscpu | grep -i -E 'numa|thread|socket'
numactl --hardware
If you see more than one NUMA node, keep each group of workers and its memory together. numactl can bind a process to one node’s CPUs and memory, and because availableParallelism() respects that binding, the cluster example above sizes itself to the node automatically:
# One cluster per NUMA node, each on its own port behind your load balancer
PORT=3000 numactl --cpunodebind=0 --membind=0 node cluster-server.mts &
PORT=3001 numactl --cpunodebind=1 --membind=1 node cluster-server.mts &
Be careful with --membind. It only allocates from the nodes you list, and when they run out the allocation fails instead of borrowing from a neighbour, so leave headroom or use --preferred instead.
Gotchas Before You Fork 512 Workers
- More workers can be slower. Past the point where memory bandwidth or the database is the limit, adding processes adds contention. Raise the count in steps and watch latency, not just throughput.
- A restart loop can become a fork bomb. The
exithandler above restarts any worker that dies. If a worker crashes on startup, you’ll restart it forever. Count recent restarts and back off. - Clean shutdowns trigger restarts. On deploy, tell the primary you’re shutting down so the
exithandler doesn’t bring workers back. UV_THREADPOOL_SIZEis per process. Twelve cluster workers with a pool of 16 each is 192 helper threads, plus the workers themselves.
Use the Building You’re Paying For
The new chips are a genuine gift for Node developers, because Node’s model of many small, mostly waiting tasks is exactly what they were built for. You don’t need a rewrite to use them. Count the CPUs you’re allowed to use, give each one a worker, keep slow jobs off the event loop, and size the helper pool on purpose. Then go look at the memory layout, because that’s where the next wall is.
Next time you look at a quiet CPU graph on a big machine, ask yourself:
When our CPU graph says 12%, is that because we’re efficient or because we’re single-threaded?