We all know.
event-loopTherefore, it saves server resources and has relatively high performance.
I can understand saving resources, but high performance. Although I can understand part of it, I assumed a scenario and then I couldn’t think of it.
For example, there is a function, the function body is mainly to query the data of a database table, assuming that there are at the same time
10000Time of concurrent quantity to access, then the next assumption
10000After the second execution was completed in an instant,
task queueThere will be one in inside at this time.
10000Of callback functions waiting to be executed are queued.
If you look at it this way, the performance will not necessarily be fast, or
nodeIs there an appropriate response mechanism?
javaIn this case, I can use multiple servers to deploy in a distributed way, and use the amount of hardware to break this bottleneck (although the overhead on money is just. . )
nodeIf you do,
Central ProcessorIs the direct bottleneck, then how to deal with this problem?
nodeThis is what I don’t understand now. Please be a great god for advice ~
We look at node’s efficiency from two angles.
First, from the perspective of tools
When we are preparing to make a product or realize a function, one of the most important steps is technology selection, which is evaluated according to the characteristics of the product and the development of Period (the situation is really complicated and many factors will affect the technology selection)
Node has the advantage that the threshold for dynamic language learning is relatively low (c/c plus).
Second, from a performance point of view
It won’t be as inefficient as the LAMP multiprocess passed by PHP.
Single thread asynchronous feature project can have good throughput even if the front and back ends are not separated in the early stage.
Three: But there are also shortcomings.
Late in the project, single-thread asynchronous programming is more complicated than traditional synchronous logic debugging.
The operating performance of the bottom layer is too low, such as operating files.
Dynamic languages do not have strict variable types, which makes debugging difficult for large projects, but these problems can be solved by using the existing typescript.
Four: if used correctly
Now what I do in the project is that node is only responsible for rendering pages as an intervention layer, sending requests to api servers and putting them into message queues, and the consumer uses go to implement business logic (ensuring high efficiency and stability).