
Node.js Interview Question: Concurrency or Parallelism?
Concurrency vs Parallelism, Explained With One CPU Core!
A single-core Node server handling 10,000 open connections at once looks like magic, but it's just concurrency. When a request is waiting on a database or disk, the core doesn't sit idle. It switches to the next request and comes back once the data is ready, so thousands of tasks make progress by taking turns while only one actually runs at any instant.
Parallelism is different. Give the server four cores and four requests run at the exact same physical moment. But four cores won't speed up Node on their own. Node runs your JavaScript on a single thread, so out of the box it touches one core. To use all four, you run four copies of the process behind a load balancer.
Rule of thumb: if the work is mostly waiting (databases, files, vendors), concurrency wins and one core goes a long way. If the work is mostly computing (resizing images, training a model), only parallelism makes it faster.
Which one would you reach for first, concurrency or parallelism? Drop your answer below.
#Concurrency #Parallelism #NodeJS #SystemDesign #BackendDevelopment #CodingInterview #DevOps #Multithreading #CPU #WebDevelopment #SoftwareEngineering #TechInterview #ProgrammingInterview
A single-core Node server handling 10,000 open connections at once looks like magic, but it's just concurrency. When a request is waiting on a database or disk, the core doesn't sit idle. It switches to the next request and comes back once the data is ready, so thousands of tasks make progress by taking turns while only one actually runs at any instant.
Parallelism is different. Give the server four cores and four requests run at the exact same physical moment. But four cores won't speed up Node on their own. Node runs your JavaScript on a single thread, so out of the box it touches one core. To use all four, you run four copies of the process behind a load balancer.
Rule of thumb: if the work is mostly waiting (databases, files, vendors), concurrency wins and one core goes a long way. If the work is mostly computing (resizing images, training a model), only parallelism makes it faster.
Which one would you reach for first, concurrency or parallelism? Drop your answer below.
#Concurrency #Parallelism #NodeJS #SystemDesign #BackendDevelopment #CodingInterview #DevOps #Multithreading #CPU #WebDevelopment #SoftwareEngineering #TechInterview #ProgrammingInterview
KodeKloud
...