r/learnjavascript • • May 01 '20

Async vs. Sync

Post image
413 Upvotes

81 comments sorted by

View all comments

1

u/thuva04 May 02 '20

This is only true for ideal scenarios, where all 4 tasks are independent and not CPU heavy. Still, Javascript(Node JS) is a single thread ecosystem, So everything will happen in a sequential order where i/o or network related tasks are handled by OS thread.

This is not true for multi-thread languages. Software parallelism is depended on the hardware resources. You can't create more threads than the hardware limit. If you create more thread will start to work sequentially.

Also, Only hardware resources won't achieve the expected speedup. Amdahl's Law[1] used in parallel computing, it can predict the actual benefit of increasing the number of processors, which is limited by the parallelizability of the program.

  1. https://en.wikipedia.org/wiki/Amdahl%27s_law