Standard inter-process communication (IPC) channels in Node.js serialize and copy payloads through JSON pipes, adding latency and memory fragmentation under heavy traffic. By leveraging Unix Domain Sockets (UDS) and Linux kernel SCM_RIGHTS ancillary messages, master processes pass open TCP/TLS file descriptors directly into worker processes with zero buffer copying, enabling seamless socket migration and maximum core utilization.
The Architecture of Ancillary Control Messages & Descriptor Migration
How sendmsg(2) and recvmsg(2) transfer kernel descriptor ownership across process boundaries:
When passing a descriptor via child.send(handle), Node.js embeds the open socket file descriptor into a cmsghdr structure with type SCM_RIGHTS. The Linux kernel duplicates the underlying file table entry into the receiving worker's file descriptor table ($fd$), immediately adding it to the worker's epoll instance with zero network re-binding.
IPC Mechanisms in Node.js Compared
| IPC Mechanism | Data Transfer Method | Throughput Capacity | Socket Migration Support |
|---|---|---|---|
| Standard JSON IPC Channel (process.send) | Serialization + Memory Copy | 25,000 msgs/sec (V8 GC overhead) | No (Data only) |
| SharedArrayBuffer + Atomics | Shared Memory (Worker Threads) | 1,500,000+ ops/sec | No (Threads only, not processes) |
| Unix Domain Sockets (SCM_RIGHTS) | Kernel Table Entry Transfer | Direct Kernel Handoff (Zero-Copy) | Full Native Support |
Master-to-Worker Socket Handoff in Node.js
Distributing incoming TCP client connections across isolated worker processes:
import net from 'node:net';
import { fork, ChildProcess } from 'node:child_process';
import os from 'node:os';
const numCPUs = os.cpus().length;
const workers: ChildProcess[] = [];
let nextWorker = 0;
for (let i = 0; i < numCPUs; i++) {
workers.push(fork('./worker.js'));
}
// Master listener accepts TCP socket and delegates via SCM_RIGHTS
const server = net.createServer({ pauseOnConnect: true }, (socket) => {
const worker = workers[nextWorker];
nextWorker = (nextWorker + 1) % workers.length;
worker.send('handle', socket);
});
server.listen(8080, () => {
console.log('[MASTER] Zero-copy SCM_RIGHTS socket dispatcher listening on :8080');
});
Explore Advanced Node.js Systems Architecture
Scale backend microservices with native Linux kernel features. Read our guide on Node.js Process Sandboxing & Landlock LSM, review hypergraph semantic traversal on LinkDepot Hypergraph Traversal, explore event-driven schema evolution on CWP Schema Registries, or consult with our senior Node.js architects.
