`
13146489
  • 浏览: 251491 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

NODE.JS是什么

阅读更多
1、一个连接一个进程
2、能处理很多的并发连接
3、使用的场景:
What it's good for
As you've seen so far, Node is extremely well designed for situations where you are expecting a high amount of traffic and the server-side logic and processing required isn't necessarily large before responding to the client. Good examples of where Node would excel include:

A RESTful API

A web service that provides a RESTful API takes in a few parameters, interprets them, pieces together a response, and flushes a response (usually a relatively small amount of text) back to the user. This is an ideal situation for Node, because you can build it to handle tens of thousands of connections. It also doesn't require a large amount of logic; it just looks up values from a database and pieces together a response. Since the response is a small amount of text, and the incoming request is a small amount of text, the traffic volume isn't high, and one machine can likely handle the API demands of even the busiest company's API.
Twitter queue
Think about a company like Twitter that has to receive tweets and write them to a database. There are literally thousands of tweets arriving every second, and the database can't possibly keep up with the number of writes required during peak usage times. Node becomes an important cog in the solution to this problem. As we've seen, Node can handle tens of thousands of incoming tweets. It can write them quickly and easily to an in-memory queuing mechanism (memcached for example), from which another separate process can write them to the database. Node's role in this is to quickly gather the tweet and pass this information off to another process responsible for writing it. Imagine another design — a normal PHP server that tries to handle writes to the database itself — every tweet would cause a small delay as its written to the database since the database call would be blocking. A machine with this design may only be able to handle 2000 incoming tweets a second, due to the database latency. A million tweets per second requires 500 servers. Node, instead, handles every connection and doesn't block, enabling it to capture as many tweets as possible. A node machine able to handle 50,000 tweets per second requires only 20 servers.
Image file server
A company that has a large distributed website (think Facebook or Flickr), could decide to devote entire boxes to simply serving up images. Node would be a good solution for this problem because the company can use it to code an easy file retriever and then handle tens of thousands of connections. Node would look for the image file, return it or a 404 error, and do nothing else. This setup would allow these types of distributed websites to reduce the number of server boxes they need to serve static files such as images, .js files, and .css files.
What it's bad for
Of course, Node is not the ideal choice in some situations. Here are scenarios where Node would not excel:
Dynamically created pages
Currently, Node doesn't provide a default way to create dynamic pages. For example, when using JavaServer Pages (JSP) technology you can create an index.jsp page that contains loops in JSP snippets like <% for (int i=0; i<20; i++) { } %>. Node doesn't enable these types of dynamic HTML-driven pages. Again, Node isn't ideally suited to be a web page server, as Apache and Tomcat are. Therefore, if you wanted to provide a server-side solution for this in Node, you'd have to code the entire solution yourself. A PHP programmer wouldn't want to program a PHP converter for Apache every time they deployed a web application, but at this point, that's what Node would require you to do.
Relational database heavy applications
Node is designed to be fast, asynchronous, and non-blocking. Databases don't necessarily share these goals. They are synchronous and blocking, as calls to the database on writes and reads block until a result is generated. So, a web application that requires a lot of database calls, a lot of reads, and a lot of writes with every request would be a bad match for Node, since the relational database itself would be negating many of the strengths of Node. (The new NoSQL databases are a better match for Node, but that's another topic entirely.)


Node accomplishes its goals of providing highly scalable servers. It doesn't allocate a thread-per-connection model, but instead uses a process-per-connection model, creating only the memory that is required for each connection. It uses an extremely fast JavaScript engine from Google, the V8 engine. It uses an event-driven design to keep code minimal and easy-to-read. All of these factors lead to Node's desired goal — it's relatively easy to write a massively scalable solution.

http://www.ibm.com/developerworks/opensource/library/os-nodejs/index.html
分享到:
评论

相关推荐

    Node.js(node-v16.15.1-win-x64.zip)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js(node-v16.15.1-win-x86.zip)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    node.js14.18.3版本下载

    Node.js 是一个开源、跨平台的 JavaScript 运行环境,它允许开发者在服务器端执行 JavaScript 代码。Node.js 使用 V8 引擎,这是 Google 为 Chrome 浏览器开发的高性能 JavaScript 和 WebAssembly 引擎。Node.js 的...

    Node.js开发-Node.js入门.pdf

    Node.js 是一个基于 JavaScript 的服务器端运行平台,允许开发者使用 JavaScript 语言来编写服务器端应用程序。 Node.js 的出现使得 JavaScript 成为服务器端脚本语言。 Node.js 的主要特点是非阻塞 I/O 和事件驱动...

    Node.js英文书籍2015出版共9本(一次下载)

    Full Stack Javascript - Learn Backbone.js, Node.js and MongoDB (APress 2015).epub Learning Node.js for Mobile Application Development (Packt 2015).pdf Microsoft Press Node.js for .NET Developers (2015...

    node.js(v16.16.0) 安装包

    Node.js 是一个开源、跨平台的 JavaScript 运行环境,它让开发者可以在服务器端执行 JavaScript 代码。Node.js 使用了 Google V8 引擎,这个引擎是为 Chrome 浏览器设计的,因此 Node.js 具有高性能和高效性的特点。...

    Node.js(node-v16.15.1.pkg)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js-Node.jsforMobileApps是用于Android和iOS的完整版Node.js运行时

    标题中的“Node.js-Node.js for Mobile Apps”指的是将Node.js环境移植到移动设备上,使得开发者能够在Android和iOS平台上直接运行Node.js应用程序。这一技术的出现极大地拓展了JavaScript的适用范围,不再局限于Web...

    Node.js(node-v16.15.1.tar.gz 源码)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js(node-v16.15.1-x64.msi)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    node.js官方v14.17.3-x64版本msi安装包【集成npm】

    Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,它允许开发者在服务器端使用 JavaScript 进行编程。v14.17.3 是 Node.js 的一个稳定版本,针对 x64(64位)架构设计。集成的 npm (Node Package Manager)...

    Node.js官方工具14.17.3版本windows系统x64安装包

    Node.js是一种开源、跨平台的JavaScript运行环境,它允许开发者在服务器端运行JavaScript代码,极大地扩展了JavaScript的应用领域。Node.js基于Chrome V8引擎,因此它具有高性能和高效的特性。标题提到的是Node.js的...

    Node.js(node-v16.15.1-linux-arm64.tar.xz)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js(node-v16.15.1-linux-x64.tar.xz)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js(node-v16.15.1-aix-ppc64.tar.gz)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Beginning Node.js

    From this book you will learn how to write maintainable server-side JavaScript using Node.js, how to test your code and deploy it on the internet. Table of Contents Chapter 1: Setting up for Node.js...

    Node.js Javascript运行环境(runtime environment)

    Node.js是一个Javascript运行环境(runtime environment),发布于2009年5月,由Ryan Dahl开发,实质是对Chrome V8引擎进行了封装。Node.js对一些特殊用例进行优化,提供替代的API,使得V8在非浏览器环境下运行得更好...

    Node.js(node-v16.15.1-x86.msi)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

    Node.js(node-v21.6.0.tar.xz)

    Node.js是一个基于V8引擎的开源、跨平台的JavaScript运行环境,用于执行JavaScript代码。它允许开发者使用JavaScript编写服务器端应用程序,使得前后端语言统一,提高开发效率。Node.js提供了一个非阻塞I/O模型,使...

    Node.js(node-v16.15.1-darwin-arm64.tar.gz)

    Node.js 应用程序是用 JavaScript 编写的,可以在 Mac OS X、Windows 和 Linux 上的 Node.js 运行时中运行而无需更改。 Node.js 应用程序旨在最大限度地提高吞吐量和效率,使用非阻塞 I/O 和异步事件。Node.js 应用...

Global site tag (gtag.js) - Google Analytics