0

I heard the reason that MongoDB and other Node.js programs are fast is because they do everything at the same time with async, but when I run a Node program, I only see one thread on my system. What's wrong? Have they not finished this feature yet? If not, how can this be faster than PHP/Apache, where they will run many threads instead of wasting system resources sitting idle?

3 Answers3

1

async is not the same as multi thread. those are two different things.

Asynchronous means that the thread doesn't need to wait for the response of a function call before doing other things. you can however mix async with multi threading but that does not mean that they are the same.

taxicala
  • 21,408
  • 7
  • 37
  • 66
1

Asynchronous programming does not necessarily mean multi-threaded.

Asynchronous only means that the data can be transmitted intermittently rather than in a steady stream.

For example, Javascript is a single-threaded runtime that make use of Asynchronous Communication.

Marco x
  • 21
  • 3
0

You can have multiple processes and/or workers in node.js too.

Community
  • 1
  • 1
Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100