Vertical Scaling with Node.js: Threads.

Do you really know the difference between an algorithm and a text file? If your answer is no, you probably wanna start here. This section is a follow-up. In the previous one, we agreed on a few key ideas: CPU-bound – All the heavy lifting happens inside your processor. I/O-bound – Your code is waiting on external entities (files, networks, that one slow AWS API). Knowing the difference between the two is foundational to scaling. Because how do you scale something like an FFmpeg node worker? video -> [READ: I/O][PROCESS: CPU][WRITE: I/O] -> output We used the restaurant analogy: Your Computer Is a Kitchen Main thread = Head chef Cores = Workstations Programming language = Knives/utensils I/O = Delivery trucks outside Scaling Laws of the Kitchen: More trucks ≠ faster chopping (Adding I/O won’t fix CPU limits) Better knives ≠ faster deliveries (Optimizing code won’t fix slow disks, networks, or databases) Now let’s talk scaling: Vertical – Beefing up one machine with more memory and cores Horizontal – Distributing work across internal clusters (processes) or separate machines In this article, we’ll zoom in on one type of vertical scaling: Threads. Threads

May 14, 2025 - 13:08
 0
Vertical Scaling with Node.js: Threads.

Do you really know the difference between an algorithm and a text file?

If your answer is no, you probably wanna start here.

This section is a follow-up.

In the previous one, we agreed on a few key ideas:

  • CPU-bound – All the heavy lifting happens inside your processor.
  • I/O-bound – Your code is waiting on external entities (files, networks, that one slow AWS API).

Knowing the difference between the two is foundational to scaling.

Because how do you scale something like an FFmpeg node worker?

video -> [READ: I/O][PROCESS: CPU][WRITE: I/O] -> output

We used the restaurant analogy:

Your Computer Is a Kitchen

  • Main thread = Head chef
  • Cores = Workstations
  • Programming language = Knives/utensils
  • I/O = Delivery trucks outside

Scaling Laws of the Kitchen:

  1. More trucks ≠ faster chopping (Adding I/O won’t fix CPU limits)
  2. Better knives ≠ faster deliveries (Optimizing code won’t fix slow disks, networks, or databases)

Now let’s talk scaling:

  • Vertical – Beefing up one machine with more memory and cores
  • Horizontal – Distributing work across internal clusters (processes) or separate machines

In this article, we’ll zoom in on one type of vertical scaling: Threads.

Threads