05 / 09

What is process management?

In a server-side application, multiple processes can be running simultaneously, each of which has its own memory space and runtime environment. Process management refers to the ways in which these processes are created, managed, and terminated.

There are three primary ways to create a child process in Node.js:
  1. 1

    exec.

  2. 2

    fork.

  3. 3

    spawn.

Difficulty: 5/10
Topics: child_process, cluster, process monitoring

Scenario Questions

0-2 years experience
  1. 1

    How would you spawn a child process in Node.js to run a shell command, and how would you capture its output?

  2. 2

    If a child process you started exits with a non‑zero code, what steps would you take in your Node.js code to handle it?

  3. 3

    What happens if you forget to call child.unref() on a detached process?

2-5 years experience
  1. 1

    You added a new feature that uses child_process.exec to run a script, but the application sometimes hangs. How would you debug the issue?

  2. 2

    When using the cluster module to take advantage of multiple CPU cores, what trade‑offs do you consider regarding state sharing and graceful shutdown?

  3. 3

    Why might using exec instead of spawn cause memory problems in a high‑traffic Node service?

5-8 years experience
  1. 1

    Design a process management strategy for a Node.js microservice that must stay up 99.99% and handle traffic spikes, considering clustering, monitoring, and zero‑downtime restarts.

  2. 2

    How would you implement graceful shutdown of a Node.js server that has multiple worker processes handling in‑flight requests?

  3. 3

    Explain how you would decide between using the built‑in cluster module versus an external manager like PM2 in a large‑scale deployment.

8+ years experience
  1. 1

    At an organization level, how would you standardize process management across many Node.js services to ensure consistent observability, restart policies, and resource limits?

  2. 2

    Describe the architectural implications of moving from a monolithic Node.js app using cluster to a container‑orchestrated system (e.g., Kubernetes) that manages processes for you.

  3. 3

    What long‑term maintenance challenges arise from relying on custom process‑management code, and how would you mitigate them across teams?

Follow-up Questions

  • What specific Node.js APIs would you use for that?
  • How would you test that your solution works under load?
  • What are the potential pitfalls you’d watch out for?