Tell me how you'd decide between threads and processes for a CPU-heavy component, and what the OS-level costs of that choice actually are.

technical-conceptual · Senior level · software-engineering

What the interviewer is really asking

Assesses understanding of the OS process/thread model — shared versus isolated address spaces, context-switch and scheduling cost, fault isolation, and IPC overhead — and the judgment to pick based on the workload rather than a default.

What to say

What to avoid

Example answers

Strong: For CPU-heavy fan-out where the pieces trust each other, I'd use a bounded thread pool sized near the core count so shared state is cheap and I avoid IPC. If a piece runs untrusted code or crashes the process, I'd isolate it in a separate process for fault containment even though that adds IPC cost. And if the runtime has a global lock, threads won't give real CPU parallelism, so I'd reach for processes there regardless.

Weak: Threads are lighter than processes and avoid the overhead of spawning, so I'd just use a big thread pool — that's the standard answer for performance.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.