This is the 21st day of my participation in Gwen Challenge
Node has a large base of JavaScript programmers and is completely open source! Hence a strong developer community! Relying on the prosperous community strength, has developed a mature technical system! And the huge ecology!
Node is widely used in
- The web service
- Development workflow
- Client application
- . And many other areas
Node has the highest acceptance in the Web services world, and is commonly used as a BFF layer, known as Backend For Frontend.
The BFF layer is, in plain English, an intermediate rendering layer between the browser and the background. This intermediate layer is responsible for assembling the data in the microservices returned by the background. And assemble the data needed by the front end and return it to the browser, which is the background service for the front end.
Main responsibilities of BFF layer:
- Provide to users
HTTP
service - Use a backend
RPC
service
The characteristics of this kind of program do not need too strong server computing power, but the flexibility of the program has higher requirements! These two features fit nicely with Node’s strengths!
Building a Node BFF layer in the Web services domain has a number of advantages:
- For the business itself:
Node is the most suitable technology for BFF layer. A BFF layer enables the front end to freely assemble background data, which can greatly reduce business communication costs and speed up business iteration. At the same time, front-end developers can independently decide the way of communication between the front-end and the backend, which also gives front-end developers more ability to start the performance optimization of Web applications
- For back-end and operations engineers:
The construction of Node BFF layer is definitely not a task that can be completed by front-end engineers alone. In the construction process, RPC calls, system operation and maintenance and other scenarios are involved, which require the close cooperation between the back end and operation and maintenance. Through the construction of BFF layer, in addition to greatly reducing their own workload in the subsequent heavy business, You can also greatly enhance your knowledge and experience in the field of architecture
- For front end engineers:
Node is a non-browser technology, but it is based on JavaScript, making it easy for front-end engineers to get started. Learning a non-browser technology is very good for learning other knowledge in the computer field. We can get involved in database, operating system, artificial intelligence and other technical fields through Node. Let front-end engineers stop looking at the browser environment because of technical barriers.
What are the difficulties of Node
Node has little to do with browser technology except JavaScript! Even data structures, design patterns, and other common programmer techniques have a different focus
For example, in the process of using Node, front-end engineers need to understand non-browser knowledge such as RPC call and process management, which will cause great trouble to some engineers with weak foundation
In addition, in the process of promoting Node, there may be questions from different roles such as product, background, operation and maintenance. Lead to front-end students using Node will encounter a variety of resistance!
Therefore, in addition to supplementing the necessary background development knowledge and system operation and maintenance knowledge, it is also necessary to have a very deep understanding of the advantages and disadvantages of Node, and the value it can bring to the business. In order to convince others to cooperate with you to complete the whole project development from the front end to the back end
What is a Node
Official website of words
Node® is a JavaScript runtime based on the Chrome V8 engine. Node uses an event-driven, non-blocking I/O model, making it lightweight and efficient
Free to understand
Components of Chrome and Node
-
Node runs JavaScript, just like Chrome runs JavaScript! It uses the same JavaScript engine and model
-
Node is mainly for the server without browser certain APIS, such as Document, window….. Added a lot of its own APIS
-
For developers, writing JavaScript to control browser Node in Chrome lets us control the entire computer in a similar way
The characteristics of the Node
Asynchronous I/O
Events and callback functions
Single thread
Node maintains the single-threaded nature of JavaScript in the browser. And there is no way for JavaScript to share any state with other threads in Node.
The biggest benefits of single threading:
There are no deadlocks and no performance costs associated with thread context exchange.
The weaknesses of single thread are as follows:
- cannot utilize multi-core cpus.
- errors cause the entire application to exit, and the robustness of the application is worth testing.
- A large number of computations occupy the CPU, causing asynchronous I/O calls to fail.
cross-platform
Node based on Libuv to achieve cross-platform architecture schematic
Compatibility with Windows and * Nix platforms is mainly due to Node’s architectural changes, which build a platform layer architecture, or Libuv, between the operating system and Node’s upper module system. At present, Libuv has become the foundation of many systems to implement cross-platform components.
With a good architecture, Node’s third-party C++ modules can also be cross-platform with libuv. Currently, most C++ modules are cross-platform compatible, with the exception of those that are not kept up to date.
What can Node be used for
Server side rendering
Node is widely used in web services
For example: Tencent video – the web page is now rendered by the server, and finally returned to the browser (view the source code in the browser, if there is a corresponding DOM structure, it is rendered by the server)
Advantages of server-side rendering
- Is conducive to SEO
- Helps speed up the first screen rendering
Server-side rendering needs to take into account the reuse of backend code
Isomorphism: The same set of code that can be used on both the back end and the front end
Build workflow
- gulp
- webpack
- .
The game
- wayward
Client application
- For example: the most popular development tool -VSCode
- New client applications need to be developed in the case of existing websites
- Using Node client technology (
eletron
) to maximize reuse of existing projects
The last
This article is shallow, you are welcome to see the officer comments left your opinion!
Feel the harvest of the students welcome to like, pay attention to a wave!
The articles
- The most complete ECMAScript walkthrough
- What is the principle of qr code scanning login
- 15 front-end hd knowledge map, strongly recommended collection
- Front end developers should know Centos/Docker/Nginx/Node/Jenkins (🍡 long)
- Let me tell you about some awesome NPM packages