Node.js 27 Coalesces Identical DNS Lookups
Node.js 27.0.0-alpha.0.1.0 shipped on November 12, 2026, and buried in its notable changes is a line that removes a bottleneck most backend teams have hit without ever naming it: dns: coalesce identical concurrent lookup() requests (PR #62599, SEMVER-MINOR).
The problem: getaddrinfo on four threads
The Node.js documentation is unusually blunt about what dns.lookup() actually is:
Though the call to dns.lookup() will be asynchronous from JavaScript's perspective, it is implemented as a synchronous call to getaddrinfo(3) that runs on libuv's threadpool.That threadpool defaults to four threads, and libuv limits how many of them slow I/O may occupy at once. Meanwhile almost every networking API that accepts a hostname — fetch, http.request, net.connect, most database drivers — resolves through dns.lookup() internally.
So a service fanning out a hundred concurrent requests to the same hostname used to dispatch a hundred separate getaddrinfo(3) calls, queued through a handful of threads that also serve fs, zlib and crypto work. When the resolver answers in a millisecond, nobody notices. When it does not — the PR cites WSL, where the DNS relay rewrites QNAMEs and glibc waits out a five-second timeout per retry — the queue itself becomes the latency, and unrelated file I/O stalls behind it.
What changed
The patch puts an in-flight map in front of getaddrinfo. When several callers request the same name at the same moment, one OS lookup is dispatched and the rest attach to it. The coalescing key is hostname, family, hints and order.
The effect shows up where nobody goes looking for it: a page gathering data from several internal services with Promise.all, a connection pool opening twenty sockets at once after a restart, a worker draining a queue in parallel. One name, many requests, each previously paying for its own system call.
The all flag is deliberately absent from that key. The shared raw result is post-processed per caller, so one caller asking for { all: true } and another asking for a single address still ride the same lookup.
Seeing it
import { lookup } from 'node:dns/promises';
const host = 'api.example.com';
const t0 = performance.now();
// One getaddrinfo(3) on Node.js 27 — one hundred of them before.
const results = await Promise.all(
Array.from({ length: 100 }, (_, i) =>
lookup(host, { family: 4, all: i % 2 === 0 })),
);
console.log(results.length, `${(performance.now() - t0).toFixed(1)} ms`);On an LTS release today, the same shape is worth writing by hand in front of any hostname a process resolves in bursts:
import { lookup } from 'node:dns/promises';
const inFlight = new Map();
export function coalescedLookup(hostname, options = {}) {
const { family = 0, hints = 0, order = 'verbatim', all = false } = options;
const key = `${hostname}\0${family}\0${hints}\0${order}\0${all}`;
const pending = inFlight.get(key);
if (pending) return pending;
const promise = lookup(hostname, options)
.finally(() => inFlight.delete(key));
inFlight.set(key, promise);
return promise;
}Note the extra all in that key. Node.js can leave it out because it shares the raw result before shaping it; a userland wrapper that hands back the already-shaped value cannot.
Caveats worth knowing
Coalescing is not caching. The map holds a lookup only while it is in flight. The next burst resolves again, and TTL-aware hostname caching remains a separate decision for the application or a library.
It covers `dns.lookup()` only. Code calling dns.resolve4() and its siblings goes over the network through c-ares, never touches the threadpool, and is untouched here.
It is scoped to one process. Separate processes resolve independently, so a clustered deployment still multiplies resolver traffic by the number of workers.
It is alpha. Node.js 27 is not an LTS line — and like the new default heap limit, it is a default that changes under code nobody edited. Review also raised that coalesced callers share a single, mutable error object, with no resolution visible in the thread. That is a reason to test the alpha, not to deploy on it.
Takeaway
The interesting part is not the saved microseconds. It is that a hidden queue — four threads shared between DNS, file I/O and compression — stops being multiplied by concurrency the application never asked for. Measure dns.lookup() burst behaviour under the alpha, decide whether a TTL cache still belongs in front of it, and keep the hand-rolled version in LTS code until 27 ships.
Primary source: Node.js 27.0.0-alpha.0.1.0 release notes and PR #62599.