Processes, Threads, and Event Loops

A process has an isolated virtual address space and operating-system resources. Threads within a process share memory and can execute concurrently, but shared state requires synchronization. Concurrency means tasks make progress during overlapping periods; parallelism means tasks execute at the same time.

An asynchronous Node.js server can serve many requests while network I/O is pending, but CPU-heavy JavaScript can still block the event loop and delay unrelated requests. Move CPU-heavy work to worker threads or separate worker processes when profiling demonstrates a bottleneck. A queue does not create capacity by itself; it moves work across time and needs a bounded size and a defined overload policy.

When designing a service, identify which tasks are I/O-bound, CPU-bound, memory-bound, or constrained by an external quota. Select process count, worker count, concurrency, and shutdown behavior based on those constraints rather than using a fixed rule of thumb.

Key Takeaways
  • Async I/O does not make CPU-heavy work non-blocking.
  • Concurrency and parallelism are distinct.
  • Bound queued work and isolate CPU-intensive tasks.