T
T
Top_Pudge2017-08-09 12:53:06
Node.js
Top_Pudge, 2017-08-09 12:53:06

What does single-threaded Node.js mean?

Let's say the Node http server is running on a dual processor server with two 36 core (72 threaded) intel xeons.
It is known that Node.js without clusters runs in one thread of execution, therefore, in one thread of the processor.
Does this mean that 143 processor threads will be idle? Do clusters solve this problem? It seems to me that no, because I have no idea how an asynchronous event loop can work on multiple threads. This means that only some calculations can be placed in workers. It seems to me personally that this is the reason Node is not used for really complex projects with a huge audience, and if Google search was written in node, no one used it because of the terrible speed of work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2017-08-09
@Top_Pudge

Does this mean that 143 processor threads will be idle

in fact yes
Server-side JS appeared not so long ago, you need to make allowances for this. Everything depends on the project and requirements, V8 is pretty well optimized inside, but if you need multithreading out of the box, then it’s better to take go with its goroutines, it’s another matter that not everyone needs it + I need to learn a new language, and so I know JS and can build a system let and single-threaded but on the usual stack.
When C++ appeared multi-core processors were not even planned yet, ways to work with multithreading were added to many languages ​​much later, somewhere more successfully, somewhere less.

I
index0h, 2017-08-09
@index0h

Does this mean that 143 processor threads will be idle?

roughly speaking yes
yes, but it's easier to run N nodejs processes through the same supervisord
It is possible, however, the expediency depends on the task at hand.
for something small, tied to an event-loop, the node is suitable, the same statsd is quite a production hl solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question