KatInterview

Concurrency models: processes vs threads

System DesignModel answer
MediumModel answerSystem Designconcurrencyoperating-systemsfundamentals

Last updated

Contrast processes and threads as concurrency primitives, covering isolation, memory models, IPC vs shared memory, and when to choose each.

Concurrency models: processes vs threads

You're designing a backend service that needs to handle work concurrently. Explain how processes and threads differ as concurrency primitives.

Your answer should cover:

  1. Core definitions: what each primitive represents at the OS level
  2. Memory model: how each manages address space and data visibility
  3. Communication: how units coordinate and share information
  4. Performance characteristics: creation cost, context switching, CPU-bound vs I/O-bound workloads
  5. Fault isolation: what happens when one unit fails
  6. Practical examples: describe 1–2 scenarios where you'd pick one over the other

Be concrete. Mention specific mechanisms (like copy-on-write, the GIL, or cache coherence) where relevant.

Hints

Hint 1

Think about what resources each primitive owns versus shares with others

Hint 2

Consider the trade-off between isolation and communication overhead

Hint 3

The Python GIL changes the calculus for CPU-bound work—why?