Ask for help from the interview question, how does node solve the problem of js single thread? what is the principle?

the concept of node has always been vague

I have always thought that node is a server, similar to nginx. During the interview, node was asked how to solve single-threaded problems

unable to express, ask for help


the nodeJS engine is single-threaded. JS communicates with cPP through V8. The CPP module is multi-threaded and handles IO operations. After the operation is completed, JS


node is called back by callback, and the event round robin mechanism is used to asynchronously perform the callback O operation, and the next request is awakened by callback callback.


cluster
Worker Threads


ides/event-loop-timers-and-nexttick/" rel=" nofollow noreferrer "> https://nodejs.org/en/docs/gu.


ide/load-balancing/" rel=" nofollow noreferrer "> pm2 tool enables multicore mode, similar to stand-alone load balancing

clipboard.png


nonenode

Menu