javascript - What does it mean for node to be the middle layer? Can you explain it in detail?
怪我咯
怪我咯 2017-05-16 13:43:16
0
5
793

I have never been exposed to node. I often read articles saying that node is used as the middle layer. I don’t know what it means specifically? For example, what problem has been solved in the program? If the rendering problem is solved, it is also on the page side and the front-end framework has been solved. Could it be that the back-end renders the front-end framework and then stuffs the whole thing into the front-end?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(5)
洪涛

In many projects, back-end applications often have more than one service, but a group of services that perform their own duties. For example, nginx exists because multiple services are running on the server, and different network requests are processed by different services. These need to be Before the service, it is assumed that a layer of nginx acts as a proxy to distribute requests to different services. The role of nginx here is equivalent to the middle layer.

For a more complex web site, requests in the page are usually divided into two types, requesting the page and requesting data (ajax). If the backend is a single application, when you find that the volume of all requests is too much to handle, you can consider such a separation, assign the request for processing the page rendering to another service, and block it in front. You are only responsible for data-related tasks. ask. Nodejs is good at handling IO-intensive tasks and is very suitable for handling page rendering services, so many people choose nodejs. Taobao has a similar architecture. It is said that all Taobao pages are now rendered by the node service.

phpcn_u1582

The truth is to use nodejs for static resource management and request forwarding.
The backend is only responsible for the data interface, and the frontend is responsible for routing and static resources.

刘奇

The middle layer of node is added, which allows the front end to process the view layer and control layer, while the back end is only responsible for processing the model layer. The separation of front-end and back-end is relatively complete, and the division of labor should be clearer.

In addition, some frameworks are more difficult to do SEO when the server is not node. After adding the node middle layer, it is easier to do SEO

为情所困

Node is chain execution

Request reception -> Middleware 1 -> Middleware 2 -> ... Middleware n ... -> Return

Middleware is a certain processing operation

phpcn_u1582

You can check out Taobao’s midway. It can be said that the core concepts are all there.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!