Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the shortcomings of nodejs?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the shortcomings of nodejs". In daily operation, I believe that many people have doubts about the shortcomings of nodejs. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the shortcomings of nodejs?" Next, please follow the editor to study!

Nodejs's disadvantages: 1, not suitable for CPU-intensive applications; 2, only support single-core CPU, can not make full use of CPU;3, low reliability; 4, open source component library quality is uneven, update fast, downward incompatible; 5, Debug is not convenient, the error does not have stack trace.

The operating environment of this tutorial: windows7 system, nodejs 12.19.0, Dell G3 computer.

Node.js is essentially a running environment for JavaScript.

Node.js is a platform based on Chrome JavaScript runtime, which is used to build network applications with fast response and easy to expand. Node.js uses event-driven, non-blocking Istroke O model to make it lightweight and efficient, which is very suitable for running data-intensive real-time applications on distributed devices.

Disadvantages of nodejs:

1. Not suitable for CPU-intensive applications

The main challenge that CPU-intensive applications bring to Node is that due to the single thread of JavaScript, if there is a long-running computation (such as a big loop), it will cause the CPU time slice to not be released and the subsequent CPU can not be initiated.

Solution: decompose large-scale computing tasks into multiple small tasks, so that the operation can be released at the right time, and does not block the initiation of the Icano call.

2. Only single-core CPU is supported, but CPU cannot be fully utilized.

3. The reliability is low. Once a part of the code crashes, the whole system crashes.

Reason: single process, single thread

4. Open source component libraries are of uneven quality, fast update and downward incompatibility.

5. Debug is not convenient, error does not have stack trace

Scenarios suitable for NodeJS

1. RESTful API

This is the ideal application scenario for NodeJS, which can handle tens of thousands of connections without too much logic. You just need to request API and organize the data to return. It essentially just looks up some values from a database and combines them into a response. Because the response is a small amount of text and the inbound request is a small amount of text, the traffic is not high, and a machine can handle the API requirements of even the busiest companies.

two。 Unify the UI layer of Web applications

The current MVC architecture, in a sense, Web development has two UI layers, one is what we finally see in the browser, and the other is on the server side, which is responsible for generating and splicing pages.

There is no discussion of whether this architecture is good or bad, but there is another practice, service-oriented architecture, to better separate dependencies from front and rear. If all the key business logic is encapsulated into REST calls, it means that the upper layer only needs to consider how to use these REST interfaces to build specific applications. Those back-end programmers don't care how specific data is passed from one page to another, and they don't care whether user data updates are obtained asynchronously through Ajax or by refreshing pages.

3. Application of a large number of Ajax requests

For example, personalized applications, each user sees a different page, cache invalidation, need to initiate Ajax requests when the page is loaded, NodeJS can respond to a large number of concurrent requests. All in all, NodeJS is suitable for scenarios with high concurrency, intensive Imax O and a small amount of business logic.

At this point, the study on "what are the shortcomings of nodejs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report