Performance: Why process management matters
HIGH IMPACT
Process management affects server responsiveness and resource usage, impacting how fast Node.js apps handle requests and stay stable under load.
import { fork } from 'child_process'; import http from 'http'; const server = http.createServer((req, res) => { const worker = fork('./heavyTask.js'); worker.on('message', () => res.end('Done')); worker.send('start'); }); server.listen(3000);
const http = require('http'); http.createServer((req, res) => { // heavy synchronous task for (let i = 0; i < 1e9; i++) {} res.end('Done'); }).listen(3000);
| Pattern | CPU Usage | Event Loop Blocking | Throughput | Verdict |
|---|---|---|---|---|
| Single process with heavy sync tasks | Low CPU utilization (1 core) | High blocking | Low throughput | [X] Bad |
| Child process offloading | Better CPU utilization | No blocking | Higher throughput | [OK] Good |
| Single process without offloading | Limited CPU usage | No blocking but limited | Moderate throughput | [!] OK |
| Clustered multi-process | Full CPU utilization | No blocking | Max throughput | [OK] Good |