js 子节点父节点兄弟节点_什么是节点js和您应该了解的其他内容

js 子节点父节点兄弟节点

Whether you have recently started learning Node.js or thinking about using it in your next project, this blog will help you in understanding the main reasons why it has become so popular, and the use cases of Node.js that you can implement for better opportunities.

无论您是最近开始学习Node.js还是在下一个项目中考虑使用它,此博客都将帮助您了解它变得如此流行的主要原因以及可以更好地实现的Node.js用例。机会。

Node.js is an open source, cross platform Javascript run-time environment for running web applications outside the client’s browser.

Node.js是一个开放源代码,跨平台的Javascript运行时环境,用于在客户端浏览器外部运行Web应用程序。

That fits in a basic scenario while creating a web application, like this -

这适合创建Web应用程序时的基本情况,例如,

Image for post

The usage of Node.js is not only limited to building web applications, but also for implementing various kinds of services.

Node.js的使用不仅限于构建Web应用程序,而且还用于实现各种服务。

  • Microservices

    微服务
  • Developing API

    开发API
  • Backends and servers

    后端和服务器
  • Scripting and automation

    脚本编写和自动化
  • Frontends

    前端

The ethos of Node.js is that it uses an asynchronous, event-driven, and non-blocking I/O model. This creates lightweight and efficient real-time applications that run across distributed devices — perfect for data intensive applications.

Node.js的精神在于它使用了异步的,事件驱动的且非阻塞的I / O模型。 这将创建可在分布式设备上运行的轻量级高效实时应用程序-非常适合数据密集型应用程序。

I know you didn’t come here after escaping the never-ending research loop only to get stuck again with event-driven, asynchronous, and other jargon.

我知道您在逃避永无止境的研究循环之后,只是为了再次陷入事件驱动的,异步的和其他术语而陷入困境。

Image for post

Let’s get to the basics to understand how these terms are solving age old problems — and also are the main reason why Node.js is heavily used among programmers and companies today.

让我们开始了解这些术语如何解决古老的问题,这也是为什么Node.js在当今的程序员和公司中得到广泛使用的主要原因。

Here’s where Node.js shines

这是Node.js的亮点

单线程 (Single Threading)

Traditional web-serving techniques use each connection (request) to spawn a new thread (the time and resources to execute a small unit of instructions). This takes up system RAM and eventually maxing-out at the amount of RAM available.

传统的Web服务技术使用每个连接(请求)生成一个新线程(执行一小段指令的时间和资源)。 这将占用系统RAM,并最终以可用RAM量最大化。

Whereas, Node.js environment is carried out by one computer processing thread that runs through a queue of events.

而Node.js环境是由一个通过一系列事件运行的计算机处理线程执行的。

Image for post

That’s because Node.js is single threaded that executes each event one by one in that queue. And you also don’t have to start a new thread for every new user and make them wait.

这是因为Node.js是单线程的,它在该队列中一个接一个地执行每个事件。 而且,您也不必为每个新用户启动新线程并让他们等待。

非阻塞I / O模型 (Non-blocking I/O model)

Image for post

Image credit: Luminousmen.com

图片来源: Luminousmen.com

I/O refers to input/output. It can be anything ranging from making an HTTP request to an API, to reading/writing local files.

I / O是指输入/输出。 从发出HTTP请求到API到读取/写入本地文件,范围可以是任何东西。

I/O takes time and hence blocks other functions.

I / O需要时间,因此会阻塞其他功能。

Node.js is non-blocking I/O, which means:

Node.js是非阻塞I / O,这意味着:

  • The server will keep attending requests.

    服务器将继续参加请求。
  • The main thread will not be blocked in I/O operations.

    主线程不会在I / O操作中被阻止。

You can initiate the requests of 2 users in parallel without waiting for the response to the request for the first user. This non-blocking I/O eliminates the need for multi-threading since the server can handle multiple requests at the same time- making the whole process fast and scalable.

您可以并行启动2个用户的请求,而无需等待对第一个用户的请求的响应。 这种无阻塞的I / O消除了对多线程的需求,因为服务器可以同时处理多个请求,从而使整个过程快速且可扩展。

异步请求处理 (Asynchronous request handling)

Image for post

An app database can be crashed with a huge data load.

应用程序数据库可能因巨大的数据负载而崩溃。

Receiving a high amount of concurrent data can make the database congested and result in the crash of the application. Also, it becomes expensive to queue data and maintains concurrency because of the huge data load.

接收大量并发数据会使数据库拥塞并导致应用程序崩溃。 而且,由于巨大的数据负载,排队数据和维护并发变得昂贵。

The asynchronous nature of Node.js helps in handling huge data load.

Node.js的异步特性有助于处理巨大的数据负载。

Asynchronous processing allows requests to be processed without blocking the thread. This helps Node.js make the most of single threading, resulting in short response time.

异步处理允许在不阻塞线程的情况下处理请求。 这有助于Node.js充分利用单线程,从而缩短响应时间。

Due to its single-threaded, non-blocking, asynchronous nature, Node.js is a popular choice for video conferences, chats, online gaming, or any solution that requires constantly updated data.

由于其单线程,非阻塞,异步的特性,Node.js是视频会议,聊天,在线游戏或任何需要不断更新数据的解决方案的流行选择。

And that’s what leads to our next section of existing use cases of Node.js.

这就是导致我们接下来的Node.js现有用例部分的原因。

Node.js中流行的用例机会 (Popular use case opportunities in Node.js)

Node.js stands out for its speed, intensive data exchange, application scalability, etc. and that is why it has been used by NASA, Netflix, Paypal and other companies.

Node.js以其速度,密集的数据交换,应用程序可伸缩性等而脱颖而出,这就是为什么它被NASA,Netflix,Paypal和其他公司使用的原因。

Below are the examples of when Node.js can and should be used:

下面是何时可以使用Node.js的示例:

1.聊天/聊天机器人: (1. Chats/Chatbots:)

The chat application is a popular example of Node.js. It helps in creating a data-intensive (but low processing/computation), high traffic, lightweight application that runs across distributed devices.

聊天应用程序是Node.js的流行示例。 它有助于创建在分布式设备上运行的数据密集型(但处理/计算量低),高流量,轻量级的应用程序。

2.微服务: (2. Microservices:)

When building and deploying microservices solutions, Node.js is the technology of choice. Companies are using two frameworks for microservice architecture. The restify is used by npm and Netflix, while the Express framework lists Uber and IBM among its users.

在构建和部署微服务解决方案时,Node.js是首选技术。 公司正在使用两种微服务架构框架。 Restify由npm和Netflix使用,而Express框架在其用户中列出了Uber和IBM。

Whereas, Walmart’s shift to microservices architecture with Node.js resulted in saving up to 40% on hardware and 20–50% on overall operations.

沃尔玛转向使用Node.js的微服务架构,从而节省了多达40%的硬件,并节省了20%至50%的总体运营成本。

3.数据流 (3. Data streaming)

Netflix chose Node.js for application scalability and intensive data exchange.

Netflix选择Node.js来实现应用程序可伸缩性和密集的数据交换。

Node.js helps in processing files while they’re still being uploaded, as the data comes in through a stream and we can process it in an online fashion. This could be done for real-time video or audio encoding and proxying between different data sources.

Node.js可帮助处理仍在上传的文件,因为数据是通过流输入的,我们可以在线方式对其进行处理。 可以为不同数据源之间的实时视频或音频编码和代理完成此操作。

4.实时数据 (4. Real time data)

There is a need to plan out extra resources to execute all the operations without failing to meet any service-level agreements if your web app is running live 24 x 7.

如果您的Web应用全天候运行7 x 7,则需要计划额外的资源来执行所有操作,而又不满足任何服务级别协议。

Node.js is a good fit for building real-time web apps by using push technology over web sockets (a two-way communication between the clients and servers).

Node.js非常适合通过在Web套接字(客户端与服务器之间的双向通信)中使用推送技术来构建实时Web应用程序。

Some applications function within a time frame that the users recognize as current and immediate. For example, collaborative web apps (Trello, Google Docs), live chat, instant messaging, and online gaming are real-time apps that benefit from Node.js architecture.

某些应用程序在用户识别为当前和立即的时间范围内运行。 例如,协作Web应用程序(Trello,Google Docs),实时聊天,即时消息传递和在线游戏都是受益于Node.js架构的实时应用程序。

结语 (Wrapping Up)

In conclusion, if your use case does not access any blocking resources nor contain CPU intensive operations, you can exploit the benefits of Node.js and enjoy scalable and fast network applications.

总之,如果您的用例不访问任何阻塞资源,也不包含占用大量CPU的操作,则可以利用Node.js的好处,并享受可扩展且快速的网络应用程序。

If you want to enter into the realm of real-time web or create a data intensive application with Node.js, Contact us.

如果您想进入实时Web领域或使用Node.js创建数据密集型应用程序,请与我们联系

Originally published at https://blog.galaxyweblinks.com on August 11, 2020.

最初于 2020年8月11日 发布在 https://blog.galaxyweblinks.com 上。

翻译自: https://medium.com/@Galaxy_Weblinks/what-is-node-js-and-other-things-you-should-know-about-it-d864e2f296c6

js 子节点父节点兄弟节点

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值