Node.jsInterview preparation
Intermediate·Concept·2 min read

Worker thread vs process: when would I use each?

Practice this question

Definition:

A process is an independently running program with its own address space and operating-system resources. A worker thread is another execution thread inside a process; Node workers have separate JavaScript execution environments and can exchange messages or share selected memory. Workers help CPU parallelism, while processes also provide stronger failure isolation.

Key points:

  • A worker thread runs JavaScript on another thread; useful for CPU-heavy work.

  • A process has its own memory and failure boundary; useful for separate app instances.

  • Use a worker pool instead of starting a new worker for every small task.

  • Include message-copying and startup costs when deciding whether a task is large enough to move to a worker.

Interview point:

  • Network waiting is usually already asynchronous; a worker is mainly useful when JavaScript computation is the bottleneck.
Adapted from 02_NODE_EXPRESS_HTTP.md · “Worker thread vs process: when would I use each?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.