F
F
Fengol2018-05-09 22:41:51
Node.js
Fengol, 2018-05-09 22:41:51

What is the difference between different ways of doing and splitting code in nodejs?

Explain with concrete examples the difference between what is called "separation of code execution". That is, when they say that by separating the processes, you will increase the performance of the application. But in my understanding, the division is limited to the division into processor cores. But in the node there is a division into child_process, into some cluster. How exactly does one way or the other separate? what is the difference?
If you answer this question, then most likely you are already well versed in the node.
Therefore, I have a request, explain about the separation as if you were explaining to yourself from the distant past
. I have no knowledge at all, except for a very meager help. I read all day
Google seems to have understood a lot, but the main thing has remained misunderstood. There are no articles in the ru segment that would be thoroughly saturated with development experience, everything I read is more like retelling and taking notes on meager documentation, like some kind of personal memo than an exhaustive guide.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
apapacy, 2018-05-09
@Fengol

A significant limitation of node.js is that the JavaScript engine can execute exactly one script or part of a script at any given time if the script uses callbacks or promises.
If multiple cores are available on the server, then you can run a node.js cluster. The easiest way to do this is with PM2, see pm2.keymetrics.io/docs/usage/cluster-mode With little to no changes to the application. With one exception. You cannot use global state (for example, the value of variables that are defined at the module level, subscription to messages, etc.). this state will be different for each instance. If necessary, to synchronize the global state, you additionally have to use, as a rule, a redis server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question