CPU Sequential Execution
To truly understand advanced backend engineering concepts like Concurrency, Thread Thrashing, and the Node.js Event Loop, you must first understand the fundamental physical limitation of a processor.
The One Task Rule
At its core, the rule of a CPU is absolute:
One CPU core can only execute exactly one instruction stream at any exact given moment.
Despite feeling like your computer is running Spotify, a Node.js server, Google Chrome, and Docker all at the exact same time, a single CPU core is physically incapable of doing two things simultaneously.
This fundamental behavior is known as Sequential Execution.
How Sequential Execution Works
When a process is actively running in RAM, the CPU looks at the Program Counter to fetch the instruction. It executes it, updates the Program Counter, and moves to the next.
- Instruction 1: Calculate
a + b - Instruction 2: Store result in variable
c - Instruction 3: Send response to network card
The CPU processes these instructions strictly one after the other. It cannot process Instruction 1 and Instruction 2 at the exact same physical millisecond on the same core.
If it's sequential, how do we multitask?
Because a single core is limited to sequential execution, Operating Systems create the illusion of multitasking through Context Switching.
The OS rapidly pauses one process, saves its state, and gives the CPU to another process. It does this thousands of times per second. Because the CPU operates at billions of cycles per second (GHz), human users perceive this rapid sequential switching as multiple tasks running "at the same time" (Concurrency).
True Parallelism
The only way to achieve true parallel execution—where two instructions are physically processed at the exact same millisecond—is to add more physical CPU cores.
If you have an 8-core CPU:
- Core 1 executes a sequence of instructions.
- Core 2 executes a different sequence of instructions simultaneously.
This is why modern high-scale backend servers require multi-core processors and utilize the Node.js cluster module to spawn multiple instances of the application across those physical cores.