AI → Full-Stack

🌐 This lesson is available in Chinese only for now. English and German translations are planned for Week 46.

Day 4 - Process Model and child_process / cluster: Opening Branches When One Waiter Isn't Enough

🧱 Three Physical Limits Even a Perfect Waiter Can't Break

Single-threaded Node.js hits three ceilings: one CPU core (no math in the main thread), file descriptor limit (OS limit), and event loop throughput (physical speed of the loop).

📇 Concept Card #1: Process vs Thread — Branches vs Waiters

Process: isolated VM, separate memory (safe but expensive). Thread: shared memory within one process (fast but dangerous).

📇 Concept Card #2: child_process Four Brothers

exec: shell command, good for scripts. execFile: no shell, faster. spawn: stream-based, best for big output. fork: new Node process, IPC channel for messaging.

Two Bombs in child_process

maxBuffer: limits stdout size. Exceed it and boom. Shell injection: if user input goes into exec, game over.

cluster: Sharing Ports Across Processes

One primary process. Workers bind to the same port. OS-level load balancing automatically. Restart one worker, others keep running.