Node.js cluster vs worker threads
When do you use cluster module vs worker_threads vs horizontal pods in Node.js?
Answers use simple, clear English.
Quick interview answer
cluster: multi-process bind same port, scale CPU on separate cores for HTTP servers. worker_threads: CPU-bound JS (image resize, crypto) off main event loop. K8s pods: scale out across machines, stateless services.
Detailed answer
cluster: multi-process bind same port, scale CPU on separate cores for HTTP servers. worker_threads: CPU-bound JS (image resize, crypto) off main event loop. K8s pods: scale out across machines, stateless services. Don't cluster inside pod if HPA already scales replicas — double scaling confusion.
Real example & use case
PDF generation in worker thread; 4 K8s replicas handle HTTP; no cluster module inside pod.
Pros & cons
Pros: right tool per bottleneck. Cons: shared memory harder across processes.