Answer the question
In order to leave comments, you need to log in
NodeJS is single-threaded, how then are large-scale projects built on it?
Good afternoon.
NodeJS is single-threaded, how then are large-scale projects built on it?
It is enough to add the code to the Authorization API:
for (let i = 0; i <= 1000000000; i++) {
console.log(i);
}
Answer the question
In order to leave comments, you need to log in
> But the same thing can happen with a long query to the database to get the user during authorization.
Can not. The point is that waiting for a response from the database / network / disk, etc. does not require any action from the node and it can do other things at this time.
As a very simplified example, run it in your browser console setTimeout(() => console.log('готово'), 5000);
. After 5 seconds, you will receive the message “done” in the console, but all this time you could use the site without any problems.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question