search

Home  >  Q&A  >  body text

javascript - What does it mean for node to be the middle layer? Can you explain it in detail?

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?

怪我咯怪我咯2749 days ago843

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:45:16

    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.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:45:16

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 13:45:16

    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

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:45:16

    Node is chain execution

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

    Middleware is a certain processing operation

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:45:16

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

    reply
    0
  • Cancelreply